]> rtime.felk.cvut.cz Git - git.git/commitdiff
git log -p -m: document -m and honor --first-parent
authorPetr Baudis <pasky@suse.cz>
Wed, 10 Feb 2010 01:11:49 +0000 (02:11 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 Feb 2010 19:32:23 +0000 (11:32 -0800)
git log -p -m is used to show one merge entry per parent, with an
appropriate diff; this can be useful when examining histories where
full set of changes introduced by a merged branch is interesting, not
only the conflicts.

This patch properly documents the -m switch, which has so far been
mentioned only as a fairly special diff-tree flag.

It also makes the code show full patch entry only for the first parent
when --first-parent is used. Thus:

git log -p -m --first-parent

will show the history from the "main branch perspective", while also
including full diff of changes introduced by other merged in branches.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/diff-generate-patch.txt
Documentation/git-log.txt
Documentation/rev-list-options.txt
log-tree.c

index 0f25ba7e3857e6c4f18c3589b31f082b602df6dc..8f9a2412fd44c80f2bf8d63271e2897ebeb3ddeb 100644 (file)
@@ -56,7 +56,8 @@ combined diff format
 
 "git-diff-tree", "git-diff-files" and "git-diff" can take '-c' or
 '--cc' option to produce 'combined diff'.  For showing a merge commit
-with "git log -p", this is the default format.
+with "git log -p", this is the default format; you can force showing
+full diff with the '-m' option.
 A 'combined diff' format looks like this:
 
 ------------
index 0e39bb61eebfce5d1bff032c65bf04bb77f8ce62..fb184ba1863845797a5f296581ec74a1b31bef1a 100644 (file)
@@ -118,6 +118,15 @@ git log master --not --remotes=*/master::
        Shows all commits that are in local master but not in any remote
        repository master branches.
 
+git log -p -m --first-parent::
+
+       Shows the history including change diffs, but only from the
+       "main branch" perspective, skipping commits that come from merged
+       branches, and showing full diffs of changes introduced by the merges.
+       This makes sense only when following a strict policy of merging all
+       topic branches when staying on a single integration branch.
+
+
 Discussion
 ----------
 
index 6e9baf8b38be5fba5e3c82e617ab95d579731884..39a064b53354d162ab0820c4af293182b9ad997b 100644 (file)
@@ -108,8 +108,8 @@ options may be given. See linkgit:git-diff-files[1] for more options.
 
 -c::
 
-       This flag changes the way a merge commit is displayed.  It shows
-       the differences from each of the parents to the merge result
+       With this option, diff output for a merge commit
+       shows the differences from each of the parents to the merge result
        simultaneously instead of showing pairwise diff between a parent
        and the result one at a time. Furthermore, it lists only files
        which were modified from all parents.
@@ -121,6 +121,15 @@ options may be given. See linkgit:git-diff-files[1] for more options.
        the parents have only two variants and the merge result picks
        one of them without modification.
 
+-m::
+
+       This flag makes the merge commits show the full diff like
+       regular commits; for each merge parent, a separate log entry
+       and diff is generated. An exception is that only diff against
+       the first parent is shown when '--first-parent' option is given;
+       in that case, the output represents the changes the merge
+       brought _into_ the then-current branch.
+
 -r::
 
        Show recursive diffs.
index 27afcf697238a48c01dd49996f5263cd72a52eac..d3ae969f608b50a469aa60b2e925558a6bb437e5 100644 (file)
@@ -514,6 +514,16 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
                        return 0;
                else if (opt->combine_merges)
                        return do_diff_combined(opt, commit);
+               else if (opt->first_parent_only) {
+                       /*
+                        * Generate merge log entry only for the first
+                        * parent, showing summary diff of the others
+                        * we merged _in_.
+                        */
+                       diff_tree_sha1(parents->item->object.sha1, sha1, "", &opt->diffopt);
+                       log_tree_diff_flush(opt);
+                       return !opt->loginfo;
+               }
 
                /* If we show individual diffs, show the parent info */
                log->parent = parents->item;