threads / discuss / 2108

Re: git-whatchanged does not show merge result?

Subject: Re: git-whatchanged does not show merge result?

## tl;dr

6 messages between Oct 14, 2005 and Oct 14, 2005.

replies: 5people: 3as markdown or json

David Ho· Oct 14, 2005, 16:33 UTC · lore
Hi,

Maybe someone can clear up a confusion I have with git-whatchanged. I created a new repo with just one file hello, split out a new branch "mybranch. When I merged back the changes from mybranch, git-whatchanged -p did not should the diff of the merge. Does it have some special behaviour I am not aware of. I'd appreciate if you can clarify. Notice that git-whatchange does not show the diff between (last commit) fd494be and 83ac91a1

Thanks, David
git version 0.99.7b
commands used (roughly to repeat the test)

mkdir git-tutorial cd git-tutorial git-init-db echo "Hello World" >hello git-update-index --add hello echo "It's a new day for git" >>hello echo "Initial commit" | git-commit-tree $(git-write-tree) > .git/HEAD git -m "added It's a new day..." commit hello git checkout -b mybranch git checkout mybranch echo "Work, work, work" >>hello git commit -m 'Some work.' hello git checkout master echo "Play, play, play" >>hello git commit -m 'Some fun.' hello git pull . mybranch vi hello (merge the change by hand...) git -m "merge work,work,... from mybranch" commit hello

last commit #cat .git/HEAD fd494becb20a8d9eddad01921de1cc9fe2cbf354

output from git-whatchanged -p hello
diff-tree 83ac91a13297887760f252aa9026e76235adcdd9 (from
7a78a9c5bb38ad4db1b5c9b14c1d409b2f36c0b0)
Author:  <davidho@penguin.nanometrics.ca>
Date:   Fri Oct 14 12:02:50 2005 -0400
    Some fun.
diff --git a/hello b/hello
--- a/hello
+++ b/hello
@@ -1,2 +1,3 @@
 Hello World
 It's a new day for git
+Play, play, play

diff-tree b12ea5026dbc9ad651fcad6b44a683548fda47a7 (from
7a78a9c5bb38ad4db1b5c9b14c1d409b2f36c0b0)
Author:  <davidho@penguin.nanometrics.ca>
Date:   Fri Oct 14 12:02:22 2005 -0400

    Some work.

diff --git a/hello b/hello
--- a/hello
+++ b/hello
@@ -1,2 +1,3 @@
 Hello World
 It's a new day for git
+Work, work, work

diff-tree 7a78a9c5bb38ad4db1b5c9b14c1d409b2f36c0b0 (from
e45b23ab79bec72ba4ef0a79820a3c172751e59b)
Author:  <davidho@penguin.nanometrics.ca>
Date:   Fri Oct 14 12:00:48 2005 -0400

    Add line "It's a new day..."

diff --git a/hello b/hello
--- a/hello
+++ b/hello
@@ -1 +1,2 @@
 Hello World
+It's a new day for git
Linus Torvalds· Oct 14, 2005, 17:13 UTC · re: David Ho · lore
On Fri, 14 Oct 2005, David Ho wrote:
Show 5 quoted lines
> 
> Maybe someone can clear up a confusion I have with git-whatchanged.
> I created a new repo with just one file hello, split out a new branch "mybranch.
> When I merged back the changes from mybranch, git-whatchanged -p did
> not should the diff of the merge.

You can use the "-m" flag to show merges. HOWEVER, it's not very useful in general, although it _is_ useful on a file-by-file basis.

What "-m" does is that it will show diffs against each parent, which is _sometimes_ what you want. Try it.

		Linus
David Ho· Oct 14, 2005, 17:31 UTC · re: Linus Torvalds · lore

I was a little worried when I did git-whatchanged on a file and there was a hole in the history where the merge is. This reassured me that all changes to the file is accessible (I'm sure they are all stored safely in the repo =).

Thanks, David
On 10/14/05, Linus Torvalds <torvalds@osdl.org> wrote:
Show 17 quoted lines
>
>
> On Fri, 14 Oct 2005, David Ho wrote:
> >
> > Maybe someone can clear up a confusion I have with git-whatchanged.
> > I created a new repo with just one file hello, split out a new branch "mybranch.
> > When I merged back the changes from mybranch, git-whatchanged -p did
> > not should the diff of the merge.
>
> You can use the "-m" flag to show merges. HOWEVER, it's not very useful
> in general, although it _is_ useful on a file-by-file basis.
>
> What "-m" does is that it will show diffs against each parent, which is
> _sometimes_ what you want. Try it.
>
>                 Linus
>
Linus Torvalds· Oct 14, 2005, 18:39 UTC · re: David Ho · lore
On Fri, 14 Oct 2005, David Ho wrote:
Show 5 quoted lines
>
> I was a little worried when I did git-whatchanged on a file and there
> was a hole in the history where the merge is.  This reassured me that
> all changes to the file is accessible (I'm sure they are all stored
> safely in the repo =).

Btw, "git-whatchanged" really _can_ hide real stuff, namely when nothing changed.

A commit that has no changes at all (which is quite possible) will never be shown by git-whatchanged.

So in many ways, "git log" is the way to see all commits. "git-whatchanged" is really just a way to see the _changes_, and by defauly it ignores merges just because the changes are "complicated".

		Linus
Junio C Hamano· Oct 14, 2005, 17:24 UTC · re: David Ho · lore
David Ho <davidkwho@gmail.com> writes:
> When I merged back the changes from mybranch, git-whatchanged -p did
> not should the diff of the merge.
You probably mean "git-whatchanged -p -m".
I've seen this question asked at least twice in the past.
    SYNOPSIS
    --------
    'git-whatchanged' <option>...
    DESCRIPTION
    -----------
    Shows commit logs and diff output each commit introduces.  The
    command internally invokes 'git-rev-list' piped to
    'git-diff-tree', and takes command line options for both of
    these commands.
    This manual page describes only the most frequently used options.

Perhaps the frequently used options should include '-m' as well. This part is from git-diff-tree.txt:

    -m::
            By default, "git-diff-tree --stdin" does not show
            differences for merge commits.  With this flag, it shows
            differences to that commit from all of its parents.

← back to recent threads