git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Célestin Matte" <celestin.matte@ensimag.fr>
Cc: Sarma Tangirala <vtangira@buffalo.edu>, git <git@vger.kernel.org>
Subject: Re: git diff bug?
Date: Thu, 06 Jun 2013 15:17:02 -0700	[thread overview]
Message-ID: <7v4ndayjdt.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <51B10236.2030009@ensimag.fr> ("Célestin Matte"'s message of "Thu, 06 Jun 2013 23:42:14 +0200")

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.

  reply	other threads:[~2013-06-06 22:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-06 21:26 git diff bug? Sarma Tangirala
2013-06-06 21:42 ` Célestin Matte
2013-06-06 22:17   ` Junio C Hamano [this message]
2013-06-07 16:01     ` Sarma Tangirala
2013-06-10 12:44       ` Célestin Matte
2013-06-10 14:41         ` Sarma Tangirala
  -- strict thread matches above, loose matches on Subject: below --
2009-04-04  1:10 David Abrahams
2009-04-04  1:45 ` Jeff King
2009-04-04  1:52   ` Jeff King
2009-04-06  9:09   ` David Abrahams
2009-04-06 14:44     ` Michael J Gruber
2009-04-06 17:58       ` David Abrahams
2009-04-06 18:48         ` Jeff King
2009-04-06 15:53     ` Jeff King
2009-04-06 17:37       ` Matthieu Moy
2009-04-06 17:56         ` Junio C Hamano
2009-04-06 19:32           ` Matthieu Moy
2009-04-06 18:16       ` David Abrahams
2009-04-07 18:25     ` Antriksh Pany

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v4ndayjdt.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=celestin.matte@ensimag.fr \
    --cc=git@vger.kernel.org \
    --cc=vtangira@buffalo.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).