gitview: Catch exception from rindex
A message that is not in the archive (sent off-list or not yet received): 392459374618773353ea560d021dd3211d143d86.1181671162.git.aneesh.kumar@gmail.com
PATCH 3/3 gitview: Catch exception from rindex
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 protected]>
--- contrib/gitview/gitview | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
contrib/gitview/gitview +7 -2
@@ -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}) (.+) (.+) (.+)$')
Signature · 1 line
1.5.2.1.239.g75d8-dirty