@matheusbsbs / matheus-bagliano / commits / 88d9d45d07
Fork 0

git log -p -m: document -m and honor --first-parent

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>

Petr Baudis committed Feb 10, 2010 at 02:11 UTC 88d9d45d071379e81e585faa95e4f28414d7d973
4 files changed +32 -3
Documentation/diff-generate-patch.txt
+2 -1
@@ -56,7 +56,8 @@ combined diff format
56
57 "git-diff-tree", "git-diff-files" and "git-diff" can take '-c' or
58 '--cc' option to produce 'combined diff'. For showing a merge commit
59 -with "git log -p", this is the default format.
59 +with "git log -p", this is the default format; you can force showing
60 +full diff with the '-m' option.
61 A 'combined diff' format looks like this:
62
63 ------------
Documentation/git-log.txt
+9
@@ -118,6 +118,15 @@ git log master --not --remotes=*/master::
118 Shows all commits that are in local master but not in any remote
119 repository master branches.
120
121 +git log -p -m --first-parent::
122 +
123 + Shows the history including change diffs, but only from the
124 + "main branch" perspective, skipping commits that come from merged
125 + branches, and showing full diffs of changes introduced by the merges.
126 + This makes sense only when following a strict policy of merging all
127 + topic branches when staying on a single integration branch.
128 +
129 +
130 Discussion
131 ----------
132
Documentation/rev-list-options.txt
+11 -2
@@ -108,8 +108,8 @@ options may be given. See linkgit:git-diff-files[1] for more options.
108
109 -c::
110
111 - This flag changes the way a merge commit is displayed. It shows
112 - the differences from each of the parents to the merge result
111 + With this option, diff output for a merge commit
112 + shows the differences from each of the parents to the merge result
113 simultaneously instead of showing pairwise diff between a parent
114 and the result one at a time. Furthermore, it lists only files
115 which were modified from all parents.
@@ -121,6 +121,15 @@ options may be given. See linkgit:git-diff-files[1] for more options.
121 the parents have only two variants and the merge result picks
122 one of them without modification.
123
124 +-m::
125 +
126 + This flag makes the merge commits show the full diff like
127 + regular commits; for each merge parent, a separate log entry
128 + and diff is generated. An exception is that only diff against
129 + the first parent is shown when '--first-parent' option is given;
130 + in that case, the output represents the changes the merge
131 + brought _into_ the then-current branch.
132 +
133 -r::
134
135 Show recursive diffs.
log-tree.c
+10
@@ -514,6 +514,16 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
514 return 0;
515 else if (opt->combine_merges)
516 return do_diff_combined(opt, commit);
517 + else if (opt->first_parent_only) {
518 + /*
519 + * Generate merge log entry only for the first
520 + * parent, showing summary diff of the others
521 + * we merged _in_.
522 + */
523 + diff_tree_sha1(parents->item->object.sha1, sha1, "", &opt->diffopt);
524 + log_tree_diff_flush(opt);
525 + return !opt->loginfo;
526 + }
527
528 /* If we show individual diffs, show the parent info */
529 log->parent = parents->item;