git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] gitview: Catch exception from rindex
       [not found] ` <fb2158f4deca7f23a86c6b3dbc80758de90cde10.1181671162.git.aneesh.kumar@gmail.com>
@ 2007-06-12 17:59   ` Aneesh Kumar K.V
  0 siblings, 0 replies; only message in thread
From: Aneesh Kumar K.V @ 2007-06-12 17:59 UTC (permalink / raw)
  To: git; +Cc: Aneesh Kumar K.V

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 <aneesh.kumar@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-12 18:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <392459374618773353ea560d021dd3211d143d86.1181671162.git.aneesh.kumar@gmail.com>
     [not found] ` <fb2158f4deca7f23a86c6b3dbc80758de90cde10.1181671162.git.aneesh.kumar@gmail.com>
2007-06-12 17:59   ` [PATCH 3/3] gitview: Catch exception from rindex Aneesh Kumar K.V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).