Subject: [PATCH 3/3] gitview: Catch exception from rindex

From: "Aneesh Kumar K.V" <[email-masked]>
Date: Tue, 12 Jun 2007 23:29:40 +0530

If we have really short read the input buffer will not
have a new line and rindex with through the ValueError
exception. Handle the same gracefully

Signed-off-by: Aneesh Kumar K.V <[email-masked]>
---
 contrib/gitview/gitview |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/contrib/gitview/gitview b/contrib/gitview/gitview
index 01128f4..4f39ddd 100755
--- a/contrib/gitview/gitview
+++ b/contrib/gitview/gitview
@@ -421,8 +421,13 @@ class AnnotateWindow(object):
 				self.prev_read = ""
 
 			if (buffer[len(buffer) -1] != '\n'):
-				self.prev_read = buffer[buffer.rindex("\n"):(len(buffer))]
-				buffer = buffer[0:buffer.rindex("\n")]
+				try:
+					newline_index = buffer.rindex("\n")
+				except ValueError:
+					newline_index = 0
+
+				self.prev_read = buffer[newline_index:(len(buffer))]
+				buffer = buffer[0:newline_index]
 
 			for buff in buffer.split("\n"):
 				annotate_line = re.compile('^([0-9a-f]{40}) (.+) (.+) (.+)$')
-- 
1.5.2.1.239.g75d8-dirty