threads / bug / 30703

Help: Found odd git bug

Subject: Help: Found odd git bug

## tl;dr

3 messages between Jun 4, 2012 and Jun 4, 2012.

replies: 2people: 2as markdown or json

Marc Branchaud· Jun 4, 2012, 16:37 UTC · lore
Hi all,

A commit claims to add a line to a file. Indeed, "git diff" shows the line being added.

However, when I check out the commit, the file contains a *different* line, with slightly modified contents.

What's more, "git show SHA:path/to/file" shows that the blob contains the wrong line.

I found this using git 1.7.9, but 1.7.11.rc1 also shows the problem.
How can I narrow down what's causing this problem?
		M.
Junio C Hamano· Jun 4, 2012, 17:52 UTC · re: Marc Branchaud · lore

Re: Help: Found odd git bug

Marc Branchaud <marcnarc@xiplink.com> writes:
Show 12 quoted lines
> A commit claims to add a line to a file.  Indeed, "git diff" shows the line
> being added.
>
> However, when I check out the commit, the file contains a *different* line,
> with slightly modified contents.
>
> What's more, "git show SHA:path/to/file" shows that the blob contains the
> wrong line.
>
> I found this using git 1.7.9, but 1.7.11.rc1 also shows the problem.
>
> How can I narrow down what's causing this problem?

Without any information useful to diagnose, I would say it probably is not a bug but is an operator error when either of the "git diff" or "check out the commit" steps were done. Even if you cannot share the repository, at least a _complete_ command line with arguments is needed.

For example, we can _reproduce_ your symptom description like this.
	$ echo this line was added >file
        $ git add file
        $ git commit -m 'added a line'
        
	$ echo another addition >file
        $ git diff
	 some context
        +another addition
	Ok, the "git diff" shows the line "another addition" being
	added.  Let's check:
	$ git show HEAD:file
	Huh? The output does not contain "another addition". What is
	going on?

What is going on in the above is an operator error, thinking the "git diff" gave the change introduced by the commit, while it asked the change to the working tree _since_ the commit.

Marc Branchaud· Jun 4, 2012, 19:52 UTC · re: Junio C Hamano · lore

Re: Help: Found odd git bug

On 12-06-04 01:52 PM, Junio C Hamano wrote:
Show 20 quoted lines
> Marc Branchaud <marcnarc@xiplink.com> writes:
> 
>> A commit claims to add a line to a file.  Indeed, "git diff" shows the line
>> being added.
>>
>> However, when I check out the commit, the file contains a *different* line,
>> with slightly modified contents.
>>
>> What's more, "git show SHA:path/to/file" shows that the blob contains the
>> wrong line.
>>
>> I found this using git 1.7.9, but 1.7.11.rc1 also shows the problem.
>>
>> How can I narrow down what's causing this problem?
> 
> Without any information useful to diagnose, I would say it probably
> is not a bug but is an operator error when either of the "git diff"
> or "check out the commit" steps were done.  Even if you cannot share
> the repository, at least a _complete_ command line with arguments is
> needed.
(Apply egg to face...)

Indeed, not a bug, nor a misunderstanding of git's workings. Rather, the offending file already had a line that the no-longer-problematic commit should have replaced, instead of adding a nearly-identical new line later on in the file. So all this basically stems from not paying enough attention to the diff's context surrounding the change.

Sorry for the false alarm, and thanks for the patient reply!
		M.

← back to recent threads