git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* how does one interpret "git diff <commit> ^<commit>"
@ 2019-02-22 13:22 Robert P. J. Day
  2019-02-22 14:04 ` Ævar Arnfjörð Bjarmason
  2019-02-22 15:30 ` Junio C Hamano
  0 siblings, 2 replies; 3+ messages in thread
From: Robert P. J. Day @ 2019-02-22 13:22 UTC (permalink / raw)
  To: Git Mailing list


  was perusing the git FAQ and ran across this:

  How do I obtain a list of files which have changed in a given commit?

     $ git diff --name-only <commit>^!


after playing with "git rev-parse", i figured out that the above was
equivalent to (using kernel "v4.19" tag as an example):

$ git diff v4.19 ^v4.19^
diff --git a/Makefile b/Makefile
index bf3786e4ffec..69fa5c0310d8 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,8 @@
 VERSION = 4
 PATCHLEVEL = 19
 SUBLEVEL = 0
-EXTRAVERSION = -rc8
-NAME = Merciless Moray
+EXTRAVERSION =
+NAME = "People's Front"

 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"
$

  but i get exactly the same output if i reverse the arguments:

$ git diff ^v4.19^ v4.19
diff --git a/Makefile b/Makefile
index bf3786e4ffec..69fa5c0310d8 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,8 @@
 VERSION = 4
 PATCHLEVEL = 19
 SUBLEVEL = 0
-EXTRAVERSION = -rc8
-NAME = Merciless Moray
+EXTRAVERSION =
+NAME = "People's Front"

 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"

  so i'm confused as to how to "git diff" interprets and processes
those two arguments, as "v4.19" is, of course, a reference to a
specific commit, but "^v4.19^" appears to define all those commits not
reachable from "v4.19^". how should one read this?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

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

* Re: how does one interpret "git diff <commit> ^<commit>"
  2019-02-22 13:22 how does one interpret "git diff <commit> ^<commit>" Robert P. J. Day
@ 2019-02-22 14:04 ` Ævar Arnfjörð Bjarmason
  2019-02-22 15:30 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2019-02-22 14:04 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Git Mailing list


On Fri, Feb 22 2019, Robert P. J. Day wrote:

>   was perusing the git FAQ and ran across this:
>
>   How do I obtain a list of files which have changed in a given commit?
>
>      $ git diff --name-only <commit>^!
>
>
> after playing with "git rev-parse", i figured out that the above was
> equivalent to (using kernel "v4.19" tag as an example):
>
> $ git diff v4.19 ^v4.19^
> diff --git a/Makefile b/Makefile
> index bf3786e4ffec..69fa5c0310d8 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2,8 +2,8 @@
>  VERSION = 4
>  PATCHLEVEL = 19
>  SUBLEVEL = 0
> -EXTRAVERSION = -rc8
> -NAME = Merciless Moray
> +EXTRAVERSION =
> +NAME = "People's Front"
>
>  # *DOCUMENTATION*
>  # To see a list of typical targets execute "make help"
> $
>
>   but i get exactly the same output if i reverse the arguments:
>
> $ git diff ^v4.19^ v4.19
> diff --git a/Makefile b/Makefile
> index bf3786e4ffec..69fa5c0310d8 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2,8 +2,8 @@
>  VERSION = 4
>  PATCHLEVEL = 19
>  SUBLEVEL = 0
> -EXTRAVERSION = -rc8
> -NAME = Merciless Moray
> +EXTRAVERSION =
> +NAME = "People's Front"
>
>  # *DOCUMENTATION*
>  # To see a list of typical targets execute "make help"
>
>   so i'm confused as to how to "git diff" interprets and processes
> those two arguments, as "v4.19" is, of course, a reference to a
> specific commit, but "^v4.19^" appears to define all those commits not
> reachable from "v4.19^". how should one read this?

I'm not sure if it answers your question, but search for "Jon Loeliger"
in "man git-rev-parse". It shows an example of a graph and what the ^REV
syntax means.

^v4.19^ looks cutsey, but just means:

    first_parent_of_v4.19_is_X = v4.19^
    not_reachable_from_X = ^$first_parent_of_v4.19_is_X

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

* Re: how does one interpret "git diff <commit> ^<commit>"
  2019-02-22 13:22 how does one interpret "git diff <commit> ^<commit>" Robert P. J. Day
  2019-02-22 14:04 ` Ævar Arnfjörð Bjarmason
@ 2019-02-22 15:30 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2019-02-22 15:30 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Git Mailing list

"Robert P. J. Day" <rpjday@crashcourse.ca> writes:

>   was perusing the git FAQ and ran across this:
>
>   How do I obtain a list of files which have changed in a given commit?
>
>      $ git diff --name-only <commit>^!
>
>
> after playing with "git rev-parse", i figured out that the above was
> equivalent to (using kernel "v4.19" tag as an example):
>
> $ git diff v4.19 ^v4.19^

A "rev" argument on the command line can have two (and a half but
that one does not come into picture in this discussion) polarity.
Normal and negative.  Negative revs are written with "^" prefix (not
to be confused with "^" suffix which means "the first parent of),
and normal revs are written without "^" prefix.

There are some short-hands like <rev>^!, but they expand to
combination of the normal and negative rev arguments at the bottom.
The one you used, "rev^!", on the command line expands to "rev --not
rev^1 rev^2... --not" for all its parents.  Here "--not" means
"treat all revs that follow have opposite polarity than they are
written until you see the next "--not".  For a non-merge commit,
that's equivalent to "rev --not rev^", which in turn is "rev ^rev^.

Now these normal and negative revs are often used for specifying
ranges to revision walking operations (think: "git log" etc.)  When
used to specify revision range, the set of commits a range specifies
is anything reachable from any one or more of normal revs, excluding
the ones reachable from any one or more of negative revs.  So "git
log v4.18..v4.19", which is a short-hand for "git log ^v4.18 v4.19"
(because A..B is a short-hand that expands to "^A B"), i.e. list all
commits that are reachable from v4.19, but I am not interested in
the ones that are reachable from v4.18.

"git diff" is about comparing two endpoints, so these normal and
negative revs are used differently.  With one negative and one
normal rev, you can tell "compare negative with normal to produce
a patch that takes the tree of the negative one to the tree of the
normal one".

So with "git diff v4.19^!", aka "git diff ^v4.19^ v4.19" (as v4.19
is not a merge), you are asking

	git diff v4.19^..v4.19

which is equivalent to asking

	git diff v4.19^ v4.19

which is "give me difference to bring the tree of the first parent
of v4.19 to that of v4.19".

For interactive use to see "What happend at v4.19?", it is much
easier to type "git show v4.19" than "git diff v4.19^!", though.

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

end of thread, other threads:[~2019-02-22 15:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22 13:22 how does one interpret "git diff <commit> ^<commit>" Robert P. J. Day
2019-02-22 14:04 ` Ævar Arnfjörð Bjarmason
2019-02-22 15:30 ` Junio C Hamano

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