threads / discuss / 7512

git-gui blame dividing by zero

Subject: git-gui blame dividing by zero

## tl;dr

5 messages between Apr 4, 2007 and Apr 5, 2007.

replies: 4people: 2as markdown or json

Andy Parkins· Apr 4, 2007, 15:21 UTC · lore
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
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Shawn O. Pearce· Apr 4, 2007, 15:27 UTC · re: Andy Parkins · lore

Re: git-gui blame dividing by zero

Andy Parkins <andyparkins@gmail.com> wrote:
Show 16 quoted lines
>  $ 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"

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...

-- 
Shawn.
Shawn O. Pearce· Apr 4, 2007, 16:11 UTC · re: Andy Parkins · lore

Re: git-gui blame dividing by zero

Andy Parkins <andyparkins@gmail.com> wrote:
Show 6 quoted lines
>  $ 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. ;-)

-- 
Shawn.
Andy Parkins· Apr 5, 2007, 08:33 UTC · re: Shawn O. Pearce · lore

Re: git-gui blame dividing by zero

On Wednesday 2007 April 04 17:11, Shawn O. Pearce wrote:
> 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
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Andy Parkins· Apr 5, 2007, 08:44 UTC · re: Andy Parkins · lore

Re: git-gui blame dividing by zero

On Thursday 2007 April 05 09:33, Andy Parkins wrote:
> 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
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com

← back to recent threads