Skip to content

Commit 30a8448

Browse files
kvaneeshgitster
authored andcommitted
gitview: Fix the blame interface.
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4175e9e commit 30a8448

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

contrib/gitview/gitview

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ class AnnotateWindow(object):
352352
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
353353
self.window.set_border_width(0)
354354
self.window.set_title("Git repository browser annotation window")
355+
self.prev_read = ""
355356

356357
# Use two thirds of the screen by default
357358
screen = self.window.get_screen()
@@ -401,7 +402,10 @@ class AnnotateWindow(object):
401402
def data_ready(self, source, condition):
402403
while (1):
403404
try :
404-
buffer = source.read(8192)
405+
# A simple readline doesn't work
406+
# a readline bug ??
407+
buffer = source.read(100)
408+
405409
except:
406410
# resource temporary not available
407411
return True
@@ -411,6 +415,19 @@ class AnnotateWindow(object):
411415
source.close()
412416
return False
413417

418+
if (self.prev_read != ""):
419+
buffer = self.prev_read + buffer
420+
self.prev_read = ""
421+
422+
if (buffer[len(buffer) -1] != '\n'):
423+
try:
424+
newline_index = buffer.rindex("\n")
425+
except ValueError:
426+
newline_index = 0
427+
428+
self.prev_read = buffer[newline_index:(len(buffer))]
429+
buffer = buffer[0:newline_index]
430+
414431
for buff in buffer.split("\n"):
415432
annotate_line = re.compile('^([0-9a-f]{40}) (.+) (.+) (.+)$')
416433
m = annotate_line.match(buff)

0 commit comments

Comments
 (0)