# git diff bug?

6 messages from 2013-06-06 to 2013-06-10. Participants: Sarma Tangirala, Célestin Matte, Junio C Hamano.
Thread: https://gitlist.dev/t/34041

## Sarma Tangirala, 2013-06-06 21:26

Subject: git diff bug?
Message-ID: <CANd8icJ_1mqT9m-n3wPPdjzG1oNjwxfQeUA6YL6KVxbq0iEa1g@mail.gmail.com>
URL: https://gitlist.dev/e/CANd8icJ_1mqT9m-n3wPPdjzG1oNjwxfQeUA6YL6KVxbq0iEa1g%40mail.gmail.com

```
Hello All,

If I did 'git diff HEAD^..HEAD -- file' should git not report some
kind of warning if it could not match the file? For example, if 'file'
were infact 'dir/file' and 'file' were unique, would it not be a good
idea to report that in the present working directory 'file' were not
found but 'dir/file' were a match?

Apologies if I missed this in the man page.

Thanks

--
010
001
111

```

## Célestin Matte, 2013-06-06 21:42

Subject: Re: git diff bug?
Message-ID: <51B10236.2030009@ensimag.fr>
URL: https://gitlist.dev/e/51B10236.2030009%40ensimag.fr
In-Reply-To: <CANd8icJ_1mqT9m-n3wPPdjzG1oNjwxfQeUA6YL6KVxbq0iEa1g@mail.gmail.com>

```
Le 06/06/2013 23:26, Sarma Tangirala a écrit :
> Hello All,
> 
> If I did 'git diff HEAD^..HEAD -- file' should git not report some
> kind of warning if it could not match the file? For example, if 'file'
> were infact 'dir/file' and 'file' were unique, would it not be a good
> idea to report that in the present working directory 'file' were not
> found but 'dir/file' were a match?

I don't know any program doing such a thing, and I don't think it is the
role of the program to predict which file the user actually wanted to
provide in the command line.
That would imply looking for files with the same name or a close name in
the current directory and its subdirectories - and maybe even in the
superdirectory? It is hard to decide when you have to stop looking for
the file.

```

## Junio C Hamano, 2013-06-06 22:17

Subject: Re: git diff bug?
Message-ID: <7v4ndayjdt.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v4ndayjdt.fsf%40alter.siamese.dyndns.org
In-Reply-To: <51B10236.2030009@ensimag.fr>

```
Célestin Matte <celestin.matte@ensimag.fr> writes:

> Le 06/06/2013 23:26, Sarma Tangirala a écrit :
>> Hello All,
>> 
>> If I did 'git diff HEAD^..HEAD -- file' should git not report some
>> kind of warning if it could not match the file? For example, if 'file'
>> were infact 'dir/file' and 'file' were unique, would it not be a good
>> idea to report that in the present working directory 'file' were not
>> found but 'dir/file' were a match?
>
> I don't know any program doing such a thing, and I don't think it is the
> role of the program to predict which file the user actually wanted to
> provide in the command line.
> That would imply looking for files with the same name or a close name in
> the current directory and its subdirectories - and maybe even in the
> superdirectory? It is hard to decide when you have to stop looking for
> the file.

The parameters after "--" are pathspecs, which is a set of patterns
the paths discovered by the operation (in this case "diff" that
finds paths in HEAD^ and HEAD) are matched against.  They are used
to filter out uninteresting paths.

If HEAD^ and HEAD does not have anything that match the given
pattern (in this case, literal four-letter string "file"), the set
of interesting paths may become empty and that is perfectly normal.

So this is working as designed.

Having said that, we do detect typo by noticing when a pathspec did
not find _any_ path that matched it in some front-end Porcelain
commands, e.g.

	$ git add 'foo*'
        fatal: pathspec 'foo*' did not match any files

It is unreasonable to do the same in "git log old..new -- path" and
error out when the pathspec does not match, because it is normal for
some revisions to have path while some other revisions to lack it.

But for a two-endpoint diff Porcelain (not the plumbing diff-files,
diff-index and diff-tree), I do not think it is particularly a bad
idea to add such a "typo-detection" feature.

```

## Sarma Tangirala, 2013-06-07 16:01

Subject: Re: git diff bug?
Message-ID: <CANd8ic+6AtWgbK3S7DMkaOz7K9WJYdq8ozP9mesc-vJRhxLjqg@mail.gmail.com>
URL: https://gitlist.dev/e/CANd8ic%2B6AtWgbK3S7DMkaOz7K9WJYdq8ozP9mesc-vJRhxLjqg%40mail.gmail.com
In-Reply-To: <7v4ndayjdt.fsf@alter.siamese.dyndns.org>

```
On Thu, Jun 6, 2013 at 6:17 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Célestin Matte <celestin.matte@ensimag.fr> writes:
>

> But for a two-endpoint diff Porcelain (not the plumbing diff-files,
> diff-index and diff-tree), I do not think it is particularly a bad
> idea to add such a "typo-detection" feature.

I was wondering if this feature is going to be added and if I could
try implementing it.

--
010
001
111

```

## Célestin Matte, 2013-06-10 12:44

Subject: Re: git diff bug?
Message-ID: <51B5CA2B.101@ensimag.fr>
URL: https://gitlist.dev/e/51B5CA2B.101%40ensimag.fr
In-Reply-To: <CANd8ic+6AtWgbK3S7DMkaOz7K9WJYdq8ozP9mesc-vJRhxLjqg@mail.gmail.com>

```
Le 07/06/2013 18:01, Sarma Tangirala a écrit :
> On Thu, Jun 6, 2013 at 6:17 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Célestin Matte <celestin.matte@ensimag.fr> writes:
>>
> 
>> But for a two-endpoint diff Porcelain (not the plumbing diff-files,
>> diff-index and diff-tree), I do not think it is particularly a bad
>> idea to add such a "typo-detection" feature.
> 
> I was wondering if this feature is going to be added and if I could
> try implementing it.

Since nobody answered you (publicly at least), I will try doing it myself:
I think the best thing to do if you want a feature to be added is to
come with a patch and request for comments on it. Then, people will
discuss it and decide whether it's worth adding it to git. So yes, you
can try implementing it - all work is welcome :)

-- 
Célestin Matte

```

## Sarma Tangirala, 2013-06-10 14:41

Subject: Re: git diff bug?
Message-ID: <CANd8icJxGO0r0iezB0hO+OhFFATDG=vV=jUJNGROs+BGMYNmzQ@mail.gmail.com>
URL: https://gitlist.dev/e/CANd8icJxGO0r0iezB0hO%2BOhFFATDG%3DvV%3DjUJNGROs%2BBGMYNmzQ%40mail.gmail.com
In-Reply-To: <51B5CA2B.101@ensimag.fr>

```
On Mon, Jun 10, 2013 at 8:44 AM, Célestin Matte
<celestin.matte@ensimag.fr> wrote:

> Since nobody answered you (publicly at least), I will try doing it myself:
> I think the best thing to do if you want a feature to be added is to
> come with a patch and request for comments on it. Then, people will
> discuss it and decide whether it's worth adding it to git. So yes, you
> can try implementing it - all work is welcome :)

That sounds great. I will try implementing and send out a patch soon!


--
010
001
111

```
