Skip to contentSkip to conversation

git-gui blame dividing by zero

DISCUSSION Andy Parkins 2 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hello,

I've not used it before, but I thought I'd give it a go:

 $ git --version
 git version 1.5.1
 $ $ git-gui --version
 git-gui version 0.6.5
 $ git-gui blame HEAD somefile.cc

I just get a window that contains:

divide by zero
divide by zero
while executing
"expr {100 * $blame_data($w,blame_lines)
/ $blame_data($w,total_lines)}"
(procedure "blame_incremental_status" line 4) invoked from within
"blame_incremental_status $w"
(procedure "read_blame_catfile" line 27)
invoked from within
"read_blame_catfile file6 {} HEAD
somefile.cc .cm.t .out.loaded_t .out.linenumber_t .out.file_t"

Am I doing something wrong?

Andy

Signature · 2 lines
Dr Andy Parkins, M Eng (hons), MIET
[email protected]
#1 lore raw
Quoted 4 lines · Andy Parkins
 $ git-gui blame HEAD somefile.cc

I just get a window that contains:

Quoted 12 lines

divide by zero
divide by zero
while executing
"expr {100 * $blame_data($w,blame_lines)
/ $blame_data($w,total_lines)}"
(procedure "blame_incremental_status" line 4) invoked from within
"blame_incremental_status $w"
(procedure "read_blame_catfile" line 27)
invoked from within
"read_blame_catfile file6 {} HEAD
somefile.cc .cm.t .out.loaded_t .out.linenumber_t .out.file_t"

Heh. So we came up with no lines in the file. Weird. What does git-blame produce on the same arguments? What about with the --incremental flag?

I'll dig into git-gui and see what I can do to more gracefully handle this condition, but right now I'm thinking we didn't get any data from git...

Signature · 1 line
Shawn.
#2 lore raw
In reply to Andy Parkins
Quoted 6 lines · Andy Parkins
 $ git-gui blame HEAD somefile.cc

I just get a window that contains:

divide by zero
divide by zero

OK, I'm a total noob sometimes. That code was obviously getting 0 into a variable, and then blindly dividing by the variable's value.

I just pushed a new patch to my git-gui.git repository, its now in both the maint and master branches. Please give that a try. ;-)

Signature · 1 line
Shawn.
#3 lore raw
Quoted 2 lines · Shawn O. Pearce

I just pushed a new patch to my git-gui.git repository, its now in both the maint and master branches. Please give that a try. ;-)

Okay - it's an improvement - no more divide by zero error. However, I don't get any output. Just an empty window with HEAD:somefile.cc in it.

The following both give lots of output:

 $ git blame HEAD -- somefile.cc 
 $ git blame --incremental HEAD -- somefile.cc

So; I think you've fixed a nasty bug, but that bug was only presenting because something else is messed up. I'll poke around and see what I can discover (however, I don't understand tk so what I discover might be that I don't understand tk :-)).

Andy

Signature · 2 lines
Dr Andy Parkins, M Eng (hons), MIET
[email protected]
#4 lore raw
Quoted 4 lines · Andy Parkins

So; I think you've fixed a nasty bug, but that bug was only presenting because something else is messed up. I'll poke around and see what I can discover (however, I don't understand tk so what I discover might be that I don't understand tk :-)).

Okay - got it. Try this in the git repository:

 # this works
 $ git-gui blame HEAD templates/hooks--commit-msg
 $ cd templates
 # this doesn't work
 $ git-gui blame HEAD hooks--commit-msg
 # this works
 $ git-gui blame HEAD templates/hooks--commit-msg

The problem is that git-gui is calling git-cat-file to read the file, but git-cat-file expects a path from the repository root. The current directory doesn't matter - you always have to type the path as if you're in the working dir root.

Andy

Signature · 2 lines
Dr Andy Parkins, M Eng (hons), MIET
[email protected]