Re: [DRAFT] Branching and merging with git

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux@...>
Cc: <git@...>
Date: Friday, November 17, 2006 - 1:55 am

linux@horizon.com writes:


Of course "git log -p --merge -- $path" would give the patch
text as well.


"show $merge" is really "diff-tree --cc -p $merge".  So first I
should (not necessarily "you should to the readers of this
document") talk about three ways to describe a merge commit with
textual diffs.

(1) N independent diffs between each of the parents and the child.

    We could get this with

    	git diff-tree -m -p $merge

    but it is mostly useless, because very often many paths in a
    merge are truly trivial and the version from one of the
    parents is taken verbatim, whole file.  When looking at the
    development history, the real reason of the change is found
    in earlier log for that parent, and not in the merge in
    question.

    The diff between the child and its first parent is somewhat
    useful, because it represents the damage inflicted on his
    branch the person saw when he made the merge.  For this
    reason, "--stat" gives the graph for the first-parent diff
    for a merge.  But otherwise "diff-tree -p" by default stays
    silent about merges because it is not that useful, and that
    is why the above asks for the "useless output ;-)" with an
    explicit "-m".

(2) Uncompressed "combined diff" between all parents and the child.

    We can get this with:

	git diff-tree -c -p $merge

    This gives a combined diff that shows all the files parents
    and child disagreed (in other words, if the resulting file
    matches verbatim with one of the parents, it is not shown).
    This is already useful by reducing the clutter of truly
    trivial merges, compared to (1) above, but most clean merges
    take either first or second parent's version verbatim for
    each hunk (but not necessarily taking all hunks from the
    same parent) and these hunks are not very interesting.

    Because "-c" explicitly tells something special to be done
    for a merge, you do not need to say "-m" for the above
    command (giving -m does not hurt, but is not necessary).
    Uncompressed combined diff is a still per-file affair, so by
    default the above gives the output in the "raw" format, and
    that is why the above command still says "-p".

(3) Compressed "combined diff".  This is what "show" gives by
    default, and we can get this with:

	git diff-tree --cc $merge

    The difference from "-c -p" output is that this reduces the
    clutter further by dropping uninteresting hunks from the
    output.  If all the changes in a hunk is from only one
    parent, or the changes are the same from all but one parent,
    the hunk is dropped from the output (looking at dodecapus
    with --cc is interesting for this reason).

    Like "-c", this explicitly asks a magic to be done on a
    merge, so "-m" is implied.  Unlike "-c", this operation is
    per-hunk and "raw" format (which is inherently per file)
    does not make any sense.  Because "raw" is impossible, "-p"
    is also implied.

Both (2) and (3) are "combined".  It combines the diffs with
each parent; for N-parent merge, it combines N diffs into one.

What -M/-C does is to see which path in each parent is used to
diff against a path in the child.  For example, the stat part
of:

	git diff-tree --stat --cc -p -M 3f69d405

shows us that builtin-apply.c had a few insertion and deletion
(remember, this is the diff between the first parent and the
child -- "damage given to the first parent due to this merge").

If you run the above without -M, you will see a huge combined
diff for builtin-apply.c because the second parent (i.e. the
branch that was merged) did not have builtin-apply.c -- it still
had the file under its old name, apply.c.

So what ends up getting combined without -M is diff between
builtin-apply.c of the first parent and the child, and diff
between /dev/null and builtin-apply.c of the child.

But with -M, what it combines is diff between builtin-apply.c of
the first parent and the child, and diff between apply.c of the
second parent and builtin-apply.c of the child.  This obviously
produces a lot more reasonable output -- actually the merge for
this particular path is texually trivial that it does not even
show in the --cc output.  You can still view what it was by
looking at:

	git diff-tree -c -p -M 3f69d405

Side note: I am not sure if the --cc hunk droppage logic is
doing the right thing for the first hunk for builtin-apply.c
case.  I think it is an "interesting" hunk but somehow --cc
output does not show it.  The second and later hunks are
definitely uninteresting, though.


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [DRAFT] Branching and merging with git, Theodore Tso, (Wed Jan 3, 1:04 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Sun Jan 7, 7:44 pm)
Re: [DRAFT] Branching and merging with git, Theodore Tso, (Sun Jan 7, 8:40 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Sun Jan 7, 8:46 pm)
Re: [DRAFT] Branching and merging with git, Guilhem Bonnefille, (Mon Jan 8, 8:38 am)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Tue Jan 9, 12:17 am)
Re: [DRAFT] Branching and merging with git , Horst H. von Brand, (Sun Jan 7, 9:46 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Sun Jan 7, 10:22 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Sun Jan 7, 8:24 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Sun Jan 7, 10:35 pm)
Re: [DRAFT] Branching and merging with git, Theodore Tso, (Mon Jan 8, 10:03 am)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Mon Jan 8, 10:41 pm)
Re: [DRAFT] Branching and merging with git, Andreas Ericsson, (Tue Jan 9, 4:46 am)
Re: [DRAFT] Branching and merging with git, Theodore Tso, (Tue Jan 9, 12:58 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Wed Jan 10, 12:15 am)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Tue Jan 9, 11:49 am)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Wed Jan 3, 1:08 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Thu Jan 4, 2:11 am)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Fri Nov 17, 1:44 pm)
Re: [DRAFT] Branching and merging with git, Theodore Tso, (Fri Nov 17, 11:32 am)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Fri Nov 17, 2:21 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Sun Nov 19, 1:50 pm)
[PATCH] Documentation: add a "git user's manual", J. Bruce Fields, (Sun Nov 26, 12:01 am)
Git manuals, Petr Baudis, (Sun Nov 19, 1:59 pm)
Re: Git manuals, J. Bruce Fields, (Sun Nov 19, 3:36 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Fri Nov 17, 8:40 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Fri Nov 17, 9:11 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Wed Nov 22, 7:51 am)
Re: [DRAFT 2] Branching and merging with git, J. Bruce Fields, (Sun Dec 3, 9:19 pm)
Re: [DRAFT 2] Branching and merging with git, J. Bruce Fields, (Mon Dec 4, 3:23 am)
Re: [DRAFT 2] Branching and merging with git, Johannes Schindelin, (Mon Dec 4, 6:56 am)
Re: [DRAFT] Branching and merging with git, Sean, (Fri Nov 17, 11:57 am)
Re: [DRAFT] Branching and merging with git, Nguyen Thai Ngoc Duy, (Fri Nov 17, 12:19 pm)
Re: [DRAFT] Branching and merging with git, Sean, (Fri Nov 17, 12:34 pm)
Re: [DRAFT] Branching and merging with git, Marko Macek, (Fri Nov 17, 12:25 pm)
Re: [DRAFT] Branching and merging with git, Petr Baudis, (Fri Nov 17, 12:33 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Thu Nov 16, 9:09 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Fri Nov 17, 1:55 am)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Thu Nov 16, 7:47 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Thu Nov 16, 9:31 pm)