All of lore.kernel.org
 help / color / mirror / Atom feed
* Inconsistency in specifying commit & path for git diff
@ 2012-10-09 19:43 Arthur Etchells
  2012-10-09 20:37 ` Andreas Schwab
  2012-10-09 21:03 ` Junio C Hamano
  0 siblings, 2 replies; 3+ messages in thread
From: Arthur Etchells @ 2012-10-09 19:43 UTC (permalink / raw)
  To: git; +Cc: Arthur Etchells

git diff <commit>..<commit>
and
git diff <commit> <commit>
both succeed

however
git diff <commit>:<path>..<commit>:<path>
fails while
git diff <commit>:<path> <commit>:<path>
succeeds

OS X 10.7.5
git version 1.7.9.1

Reproduced by another user:
http://stackoverflow.com/questions/12805004/git-cherry-pick-creates-blobs-not-commits#comment17319876_12805004

It seems logical to support the '..' syntax in both for consistency.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Inconsistency in specifying commit & path for git diff
  2012-10-09 19:43 Inconsistency in specifying commit & path for git diff Arthur Etchells
@ 2012-10-09 20:37 ` Andreas Schwab
  2012-10-09 21:03 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2012-10-09 20:37 UTC (permalink / raw)
  To: Arthur Etchells; +Cc: git

Arthur Etchells <adetchells@gmail.com> writes:

> git diff <commit>:<path>..<commit>:<path>

<commit>:<path> represents a tree or blob, but .. requires commits as
its end points.

(You can dereference a commit to get a tree or blob, but not the other
way round.)

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Inconsistency in specifying commit & path for git diff
  2012-10-09 19:43 Inconsistency in specifying commit & path for git diff Arthur Etchells
  2012-10-09 20:37 ` Andreas Schwab
@ 2012-10-09 21:03 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2012-10-09 21:03 UTC (permalink / raw)
  To: Arthur Etchells; +Cc: git

Arthur Etchells <adetchells@gmail.com> writes:

> git diff <commit>..<commit>
> and
> git diff <commit> <commit>
> both succeed
> however
> git diff <commit>:<path>..<commit>:<path>
> fails while
> git diff <commit>:<path> <commit>:<path>
> succeeds
> ...
> It seems logical to support the '..' syntax in both for consistency.

"git diff A..B" is an illogical thing to say in the first place.  It
only happens to work by historical accident, and for that "it used
to work like so from the beginning, do not break backward
compatibility" reason, we have kept it working.

But you are better off unlearning it to keep your sanity when
learning git as a new user.

The dot notation is about a range.  A..B talks about the set of
commits that are ancestors of B but not ancestors of A.

    $ git log A..B

makes perfect sense to show such a range.

But "diff" is about "comparing two endpoints".  There is nothing
"range" about such a comparison.  When you compare the state at A
and at B, you do not even look at anything in between.  That is why
the canonical way to say it is

    $ git diff A B

and not

    $ git diff A..B ;# WRONG. DO NOT DO THIS.

And <commit>:<path> is a way to name an entity at <path> in the tree
recorded in the <commit>.  Typically you name a blob, not a tree
that represents a subdirectory, with this syntax.

Now, B1..B2, when B1 and B2 are blobs (or anything that is not
commit-ish), does not make sense even as a range, and such a request
is detected as an error at the syntactic level (i.e. without even
starting to "compare").

    $ git diff HEAD:Makefile..HEAD~4:Makefile ;# WRONG. DO NOT DO THIS.

If you want to compare two blobs, you can do so with the canonical
"compare two things" syntax.

    $ git diff HEAD:Makefile HEAD~4:Makefile

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-09 21:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-09 19:43 Inconsistency in specifying commit & path for git diff Arthur Etchells
2012-10-09 20:37 ` Andreas Schwab
2012-10-09 21:03 ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.