Skip to content

Commit

Permalink
gitview: Fix the blame interface.
Browse files Browse the repository at this point in the history
The async reading from the pipe was skipping some of the
input lines. Fix the same by making sure that we add the
partial content of the previous read to the newly read
data.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Aneesh Kumar K.V authored and Junio C Hamano committed Jun 13, 2007
1 parent 4175e9e commit 30a8448
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion contrib/gitview/gitview
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ class AnnotateWindow(object):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_border_width(0)
self.window.set_title("Git repository browser annotation window")
self.prev_read = ""

# Use two thirds of the screen by default
screen = self.window.get_screen()
Expand Down Expand Up @@ -401,7 +402,10 @@ class AnnotateWindow(object):
def data_ready(self, source, condition):
while (1):
try :
buffer = source.read(8192)
# A simple readline doesn't work
# a readline bug ??
buffer = source.read(100)

except:
# resource temporary not available
return True
Expand All @@ -411,6 +415,19 @@ class AnnotateWindow(object):
source.close()
return False

if (self.prev_read != ""):
buffer = self.prev_read + buffer
self.prev_read = ""

if (buffer[len(buffer) -1] != '\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}) (.+) (.+) (.+)$')
m = annotate_line.match(buff)
Expand Down

0 comments on commit 30a8448

Please sign in to comment.