{"thread":{"id":"8576","subject":"[PATCH 3/3] gitview: Catch exception from rindex","startedAt":"2007-06-12T17:59:40Z","lastAt":"2007-06-12T17:59:40Z","messageCount":1,"participants":["Aneesh Kumar K.V"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"44854","messageId":"11816711802519-git-send-email-aneesh.kumar@gmail.com","threadId":"8576","inReplyTo":"392459374618773353ea560d021dd3211d143d86.1181671162.git.aneesh.kumar@gmail.com","subject":"[PATCH 3/3] gitview: Catch exception from rindex","fromName":"Aneesh Kumar K.V","fromEmail":"aneesh.kumar@gmail.com","sentAt":"2007-06-12T17:59:40Z","receivedAt":"2007-06-12T17:59:40Z","isPatch":true,"sender":{"key":"aneesh.kumar@gmail.com","avatar":"https://gravatar.com/avatar/0621fc0b2f14ead1e9024382f16053a808c148596da30c1b92572fa075621f68?d=mp&s=160"},"body":"If we have really short read the input buffer will not\nhave a new line and rindex with through the ValueError\nexception. Handle the same gracefully\n\nSigned-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>\n---\n contrib/gitview/gitview |    9 +++++++--\n 1 files changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/gitview/gitview b/contrib/gitview/gitview\nindex 01128f4..4f39ddd 100755\n--- a/contrib/gitview/gitview\n+++ b/contrib/gitview/gitview\n@@ -421,8 +421,13 @@ class AnnotateWindow(object):\n \t\t\t\tself.prev_read = \"\"\n \n \t\t\tif (buffer[len(buffer) -1] != '\\n'):\n-\t\t\t\tself.prev_read = buffer[buffer.rindex(\"\\n\"):(len(buffer))]\n-\t\t\t\tbuffer = buffer[0:buffer.rindex(\"\\n\")]\n+\t\t\t\ttry:\n+\t\t\t\t\tnewline_index = buffer.rindex(\"\\n\")\n+\t\t\t\texcept ValueError:\n+\t\t\t\t\tnewline_index = 0\n+\n+\t\t\t\tself.prev_read = buffer[newline_index:(len(buffer))]\n+\t\t\t\tbuffer = buffer[0:newline_index]\n \n \t\t\tfor buff in buffer.split(\"\\n\"):\n \t\t\t\tannotate_line = re.compile('^([0-9a-f]{40}) (.+) (.+) (.+)$')\n-- \n1.5.2.1.239.g75d8-dirty\n"}]}