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>
This commit is contained in:
Petr Baudis
2010-02-10 02:11:49 +01:00
committed by Junio C Hamano
parent 8051a03061
commit 88d9d45d07
4 changed files with 32 additions and 3 deletions

View 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;