git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Problem with git diff

From
Elijah Newren <newren@gmail.com>
Date
Jul 9, 2019, 23:35 UTC
Message-ID
<CABPp-BETbfzjUyYu9g83=u+HN9r3jwpK538EcOEiawBLG=uwDA@mail.gmail.com>
In-Reply-To
<CAGyf7-FeAJwWuhu-Zkccsfrcbbf3tuuOWwobsa4OOK1=hWackg@mail.gmail.com>
On Tue, Jul 9, 2019 at 4:30 PM Bryan Turner <bturner@atlassian.com> wrote:
Show 82 quoted lines
>
> On Tue, Jul 9, 2019 at 4:13 PM Elijah Newren <newren@gmail.com> wrote:
> >
> > Hi John,
> >
> > On Tue, Jul 9, 2019 at 3:57 PM McRoberts, John <John.McRoberts@ga.com> wrote:
> > >
> > > I am responsible for generating a list of all files changed between two
> > > successive releases of software. I was using 'git diff' but have run into a
> > > problem.
> > >
> > > Consider the following situation: A development branch comes off of commit A
> > > and files are changed three times.  A tag (REL1) is placed on the third
> > > commit.  Then the branch is merged back to master.  At this point, master's
> > > HEAD is at C (and it remains there).  Two development branches are created
> > > off of master, the first of which is not important here.  In the second one,
> > > there are files changed and a tag (REL2) applied.
> > >
> > >
> > > ---------------------[I]
> > >
> > > /      {dev branch}
> > >
> > > /
> > >
> > > /
> > >              {master branch}
> > > /
> > >  [A] ---------------------------------[B]------------------------------->[C]
> > > master <HEAD>
> > >    \                               filelist 6                           /  \
> > >     \                                                                  /
> > > \
> > >      \                                                                /
> > > \
> > >       \                                                              /
> > > \
> > >        \                {development branch}                        /
> > > \
> > >         \------->[D]----------------------->[E]-------------------[F]
> > > \------[G]--------[H]
> > >                                                                  REL1
> > > REL2
> > >                 fileset 1               fileset 2           fileset 3
> > > fileset 4    fileset 5
> > >
> > > At this point, I run
> > >     'git diff  -m --first-parent --pretty=fuller --decorate=short
> > > --name-only REL2..REL2'
> >
> > Wow, we really, really need to throw errors and warnings when people
> > use crazy range operators with diff.[1][2]  What version of git are
> > you using that accepts --decorate=short as an argument to `git diff`?
> > And why in the world does git diff accept --first-parent or
> > --pretty=fuller?!?  That's insane for git-diff to swallow that.
> > (#leftoverbits?)  Also, I think you meant `REL1` one of the two times
> > you wrote `REL2`, which makes me suspect you may have done some
> > copy-edit-paste and didn't try this actual command.
> >
> > > I expect to see only filesets 4 and 5 listed.  I also see filesets 1, 2 and
> > > 3 showing up.  This means that the git diff command is showing files that,in
> > > fact, did not change between the two tags.  By the way, I verified with a
> > > file by file comparison that under REL2 and REL1, the files represented by
> > > filesets 1, 2 and 3 had identical contents.
> >
> > From your description, I assume you actually ran something like
> >   git diff --name-only REL1..REL2
>
> Did you mean REL1...REL2 (3 dots)? 2 dots (REL1..REL2) is identical to
> no dots (REL1 REL2), per the documentation for "git diff":
>
>        git diff [<options>] <commit> <commit> [--] [<path>...]
>
>            This is to view the changes between two arbitrary <commit>.
>
>        git diff [<options>] <commit>..<commit> [--] [<path>...]
>
>            This is synonymous to the previous form. If <commit> on one
> side is omitted, it will have the same effect
>            as using HEAD instead.
>
> (Forgive me if I'm mistaken here!)

Yes, thanks. In trying to explain how two and three dots behave contrary to expectation for git diff, I mess up two versus three dots. That's kind of embarrassing...

Show 5 quoted lines
> > which compares REL2 to the merge base of REL1 and REL2 (yes, this is
> > totally counter-intuitive to a large percentage of the git userbase,
> > but it is well documented and hard to change).  Also from your
> > description, what you seem to want is
> >   git diff --name-only REL1 REL2

...though at least I was smart enough to suggest something without dots, which is the only sane way to use git-diff. ;-)

Previous: Bryan TurnerNext: McRoberts, John
Message 4 of 5 in “Problem with git diff”
  1. McRoberts, JohnJul 9, 2019
  2. Elijah NewrenJul 9, 2019
  3. Bryan TurnerJul 9, 2019
  4. Elijah NewrenJul 9, 2019
  5. McRoberts, JohnJul 9, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.