Merge branch 'jk/log-fp-implies-m'
"git log --first-parent -p" showed patches only for single-parent commits on the first-parent chain; the "--first-parent" option has been made to imply "-m". Use "--no-diff-merges" to restore the previous behaviour to omit patches for merge commits. * jk/log-fp-implies-m: doc/git-log: clarify handling of merge commit diffs doc/git-log: move "-t" into diff-options list doc/git-log: drop "-r" diff option doc/git-log: move "Diff Formatting" from rev-list-options log: enable "-m" automatically with "--first-parent" revision: add "--no-diff-merges" option to counteract "-m" log: drop "--cc implies -m" logicmaint
						commit
						eca8c62a50
					
				|  | @ -73,6 +73,11 @@ ifndef::git-format-patch[] | ||||||
| 	Synonym for `-p --raw`. | 	Synonym for `-p --raw`. | ||||||
| endif::git-format-patch[] | endif::git-format-patch[] | ||||||
|  |  | ||||||
|  | ifdef::git-log[] | ||||||
|  | -t:: | ||||||
|  | 	Show the tree objects in the diff output. | ||||||
|  | endif::git-log[] | ||||||
|  |  | ||||||
| --indent-heuristic:: | --indent-heuristic:: | ||||||
| 	Enable the heuristic that shifts diff hunk boundaries to make patches | 	Enable the heuristic that shifts diff hunk boundaries to make patches | ||||||
| 	easier to read. This is the default. | 	easier to read. This is the default. | ||||||
|  |  | ||||||
|  | @ -114,8 +114,47 @@ include::rev-list-options.txt[] | ||||||
|  |  | ||||||
| include::pretty-formats.txt[] | include::pretty-formats.txt[] | ||||||
|  |  | ||||||
| COMMON DIFF OPTIONS | DIFF FORMATTING | ||||||
| ------------------- | --------------- | ||||||
|  |  | ||||||
|  | By default, `git log` does not generate any diff output. The options | ||||||
|  | below can be used to show the changes made by each commit. | ||||||
|  |  | ||||||
|  | Note that unless one of `-c`, `--cc`, or `-m` is given, merge commits | ||||||
|  | will never show a diff, even if a diff format like `--patch` is | ||||||
|  | selected, nor will they match search options like `-S`. The exception is | ||||||
|  | when `--first-parent` is in use, in which merges are treated like normal | ||||||
|  | single-parent commits (this can be overridden by providing a | ||||||
|  | combined-diff option or with `--no-diff-merges`). | ||||||
|  |  | ||||||
|  | -c:: | ||||||
|  | 	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. | ||||||
|  |  | ||||||
|  | --cc:: | ||||||
|  | 	This flag implies the `-c` option and further compresses the | ||||||
|  | 	patch output by omitting uninteresting hunks whose contents in | ||||||
|  | 	the parents have only two variants and the merge result picks | ||||||
|  | 	one of them without modification. | ||||||
|  |  | ||||||
|  | --combined-all-paths:: | ||||||
|  | 	This flag causes combined diffs (used for merge commits) to | ||||||
|  | 	list the name of the file from all parents.  It thus only has | ||||||
|  | 	effect when -c or --cc are specified, and is likely only | ||||||
|  | 	useful if filename changes are detected (i.e. when either | ||||||
|  | 	rename or copy detection have been requested). | ||||||
|  |  | ||||||
|  | -m:: | ||||||
|  | --diff-merges:: | ||||||
|  | 	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. | ||||||
|  |  | ||||||
| :git-log: 1 | :git-log: 1 | ||||||
| include::diff-options.txt[] | include::diff-options.txt[] | ||||||
|  |  | ||||||
|  | @ -1116,48 +1116,3 @@ ifdef::git-rev-list[] | ||||||
| 	by a tab. | 	by a tab. | ||||||
| endif::git-rev-list[] | endif::git-rev-list[] | ||||||
| endif::git-shortlog[] | endif::git-shortlog[] | ||||||
|  |  | ||||||
| ifndef::git-shortlog[] |  | ||||||
| ifndef::git-rev-list[] |  | ||||||
| Diff Formatting |  | ||||||
| ~~~~~~~~~~~~~~~ |  | ||||||
|  |  | ||||||
| Listed below are options that control the formatting of diff output. |  | ||||||
| Some of them are specific to linkgit:git-rev-list[1], however other diff |  | ||||||
| options may be given. See linkgit:git-diff-files[1] for more options. |  | ||||||
|  |  | ||||||
| -c:: |  | ||||||
| 	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. |  | ||||||
|  |  | ||||||
| --cc:: |  | ||||||
| 	This flag implies the `-c` option and further compresses the |  | ||||||
| 	patch output by omitting uninteresting hunks whose contents in |  | ||||||
| 	the parents have only two variants and the merge result picks |  | ||||||
| 	one of them without modification. |  | ||||||
|  |  | ||||||
| --combined-all-paths:: |  | ||||||
| 	This flag causes combined diffs (used for merge commits) to |  | ||||||
| 	list the name of the file from all parents.  It thus only has |  | ||||||
| 	effect when -c or --cc are specified, and is likely only |  | ||||||
| 	useful if filename changes are detected (i.e. when either |  | ||||||
| 	rename or copy detection have been requested). |  | ||||||
|  |  | ||||||
| -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. |  | ||||||
|  |  | ||||||
| -t:: |  | ||||||
| 	Show the tree objects in the diff output. This implies `-r`. |  | ||||||
| endif::git-rev-list[] |  | ||||||
| endif::git-shortlog[] |  | ||||||
|  |  | ||||||
|  | @ -599,8 +599,8 @@ static int show_tree_object(const struct object_id *oid, | ||||||
| static void show_setup_revisions_tweak(struct rev_info *rev, | static void show_setup_revisions_tweak(struct rev_info *rev, | ||||||
| 				       struct setup_revision_opt *opt) | 				       struct setup_revision_opt *opt) | ||||||
| { | { | ||||||
| 	if (rev->ignore_merges) { | 	if (rev->ignore_merges < 0) { | ||||||
| 		/* There was no "-m" on the command line */ | 		/* There was no "-m" variant on the command line */ | ||||||
| 		rev->ignore_merges = 0; | 		rev->ignore_merges = 0; | ||||||
| 		if (!rev->first_parent_only && !rev->combine_merges) { | 		if (!rev->first_parent_only && !rev->combine_merges) { | ||||||
| 			/* No "--first-parent", "-c", or "--cc" */ | 			/* No "--first-parent", "-c", or "--cc" */ | ||||||
|  | @ -732,8 +732,7 @@ static void log_setup_revisions_tweak(struct rev_info *rev, | ||||||
| 	if (!rev->diffopt.output_format && rev->combine_merges) | 	if (!rev->diffopt.output_format && rev->combine_merges) | ||||||
| 		rev->diffopt.output_format = DIFF_FORMAT_PATCH; | 		rev->diffopt.output_format = DIFF_FORMAT_PATCH; | ||||||
|  |  | ||||||
| 	/* Turn -m on when --cc/-c was given */ | 	if (rev->first_parent_only && rev->ignore_merges < 0) | ||||||
| 	if (rev->combine_merges) |  | ||||||
| 		rev->ignore_merges = 0; | 		rev->ignore_merges = 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								revision.c
								
								
								
								
							
							
						
						
									
										10
									
								
								revision.c
								
								
								
								
							|  | @ -1815,7 +1815,7 @@ void repo_init_revisions(struct repository *r, | ||||||
|  |  | ||||||
| 	revs->repo = r; | 	revs->repo = r; | ||||||
| 	revs->abbrev = DEFAULT_ABBREV; | 	revs->abbrev = DEFAULT_ABBREV; | ||||||
| 	revs->ignore_merges = 1; | 	revs->ignore_merges = -1; | ||||||
| 	revs->simplify_history = 1; | 	revs->simplify_history = 1; | ||||||
| 	revs->pruning.repo = r; | 	revs->pruning.repo = r; | ||||||
| 	revs->pruning.flags.recursive = 1; | 	revs->pruning.flags.recursive = 1; | ||||||
|  | @ -2343,8 +2343,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg | ||||||
| 		revs->diff = 1; | 		revs->diff = 1; | ||||||
| 		revs->diffopt.flags.recursive = 1; | 		revs->diffopt.flags.recursive = 1; | ||||||
| 		revs->diffopt.flags.tree_in_recursive = 1; | 		revs->diffopt.flags.tree_in_recursive = 1; | ||||||
| 	} else if (!strcmp(arg, "-m")) { | 	} else if (!strcmp(arg, "-m") || !strcmp(arg, "--diff-merges")) { | ||||||
| 		revs->ignore_merges = 0; | 		revs->ignore_merges = 0; | ||||||
|  | 	} else if (!strcmp(arg, "--no-diff-merges")) { | ||||||
|  | 		revs->ignore_merges = 1; | ||||||
| 	} else if (!strcmp(arg, "-c")) { | 	} else if (!strcmp(arg, "-c")) { | ||||||
| 		revs->diff = 1; | 		revs->diff = 1; | ||||||
| 		revs->dense_combined_merges = 0; | 		revs->dense_combined_merges = 0; | ||||||
|  | @ -2854,8 +2856,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s | ||||||
| 			copy_pathspec(&revs->diffopt.pathspec, | 			copy_pathspec(&revs->diffopt.pathspec, | ||||||
| 				      &revs->prune_data); | 				      &revs->prune_data); | ||||||
| 	} | 	} | ||||||
| 	if (revs->combine_merges) | 	if (revs->combine_merges && revs->ignore_merges < 0) | ||||||
| 		revs->ignore_merges = 0; | 		revs->ignore_merges = 0; | ||||||
|  | 	if (revs->ignore_merges < 0) | ||||||
|  | 		revs->ignore_merges = 1; | ||||||
| 	if (revs->combined_all_paths && !revs->combine_merges) | 	if (revs->combined_all_paths && !revs->combine_merges) | ||||||
| 		die("--combined-all-paths makes no sense without -c or --cc"); | 		die("--combined-all-paths makes no sense without -c or --cc"); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @ -190,11 +190,11 @@ struct rev_info { | ||||||
| 			show_root_diff:1, | 			show_root_diff:1, | ||||||
| 			no_commit_id:1, | 			no_commit_id:1, | ||||||
| 			verbose_header:1, | 			verbose_header:1, | ||||||
| 			ignore_merges:1, |  | ||||||
| 			combine_merges:1, | 			combine_merges:1, | ||||||
| 			combined_all_paths:1, | 			combined_all_paths:1, | ||||||
| 			dense_combined_merges:1, | 			dense_combined_merges:1, | ||||||
| 			always_show_header:1; | 			always_show_header:1; | ||||||
|  | 	int             ignore_merges:2; | ||||||
|  |  | ||||||
| 	/* Format info */ | 	/* Format info */ | ||||||
| 	int		show_notes; | 	int		show_notes; | ||||||
|  |  | ||||||
|  | @ -297,6 +297,7 @@ log --root --patch-with-stat --summary master | ||||||
| log --root -c --patch-with-stat --summary master | log --root -c --patch-with-stat --summary master | ||||||
| # improved by Timo's patch | # improved by Timo's patch | ||||||
| log --root --cc --patch-with-stat --summary master | log --root --cc --patch-with-stat --summary master | ||||||
|  | log --no-diff-merges -p --first-parent master | ||||||
| log -p --first-parent master | log -p --first-parent master | ||||||
| log -m -p --first-parent master | log -m -p --first-parent master | ||||||
| log -m -p master | log -m -p master | ||||||
|  |  | ||||||
|  | @ -0,0 +1,78 @@ | ||||||
|  | $ git log --no-diff-merges -p --first-parent master | ||||||
|  | commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 | ||||||
|  | Merge: 9a6d494 c7a2ab9 | ||||||
|  | Author: A U Thor <author@example.com> | ||||||
|  | Date:   Mon Jun 26 00:04:00 2006 +0000 | ||||||
|  |  | ||||||
|  |     Merge branch 'side' | ||||||
|  |  | ||||||
|  | commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 | ||||||
|  | Author: A U Thor <author@example.com> | ||||||
|  | Date:   Mon Jun 26 00:02:00 2006 +0000 | ||||||
|  |  | ||||||
|  |     Third | ||||||
|  |  | ||||||
|  | diff --git a/dir/sub b/dir/sub | ||||||
|  | index 8422d40..cead32e 100644 | ||||||
|  | --- a/dir/sub | ||||||
|  | +++ b/dir/sub | ||||||
|  | @@ -2,3 +2,5 @@ A | ||||||
|  |  B | ||||||
|  |  C | ||||||
|  |  D | ||||||
|  | +E | ||||||
|  | +F | ||||||
|  | diff --git a/file1 b/file1 | ||||||
|  | new file mode 100644 | ||||||
|  | index 0000000..b1e6722 | ||||||
|  | --- /dev/null | ||||||
|  | +++ b/file1 | ||||||
|  | @@ -0,0 +1,3 @@ | ||||||
|  | +A | ||||||
|  | +B | ||||||
|  | +C | ||||||
|  |  | ||||||
|  | commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 | ||||||
|  | Author: A U Thor <author@example.com> | ||||||
|  | Date:   Mon Jun 26 00:01:00 2006 +0000 | ||||||
|  |  | ||||||
|  |     Second | ||||||
|  |      | ||||||
|  |     This is the second commit. | ||||||
|  |  | ||||||
|  | diff --git a/dir/sub b/dir/sub | ||||||
|  | index 35d242b..8422d40 100644 | ||||||
|  | --- a/dir/sub | ||||||
|  | +++ b/dir/sub | ||||||
|  | @@ -1,2 +1,4 @@ | ||||||
|  |  A | ||||||
|  |  B | ||||||
|  | +C | ||||||
|  | +D | ||||||
|  | diff --git a/file0 b/file0 | ||||||
|  | index 01e79c3..b414108 100644 | ||||||
|  | --- a/file0 | ||||||
|  | +++ b/file0 | ||||||
|  | @@ -1,3 +1,6 @@ | ||||||
|  |  1 | ||||||
|  |  2 | ||||||
|  |  3 | ||||||
|  | +4 | ||||||
|  | +5 | ||||||
|  | +6 | ||||||
|  | diff --git a/file2 b/file2 | ||||||
|  | deleted file mode 100644 | ||||||
|  | index 01e79c3..0000000 | ||||||
|  | --- a/file2 | ||||||
|  | +++ /dev/null | ||||||
|  | @@ -1,3 +0,0 @@ | ||||||
|  | -1 | ||||||
|  | -2 | ||||||
|  | -3 | ||||||
|  |  | ||||||
|  | commit 444ac553ac7612cc88969031b02b3767fb8a353a | ||||||
|  | Author: A U Thor <author@example.com> | ||||||
|  | Date:   Mon Jun 26 00:00:00 2006 +0000 | ||||||
|  |  | ||||||
|  |     Initial | ||||||
|  | $ | ||||||
|  | @ -6,6 +6,28 @@ Date:   Mon Jun 26 00:04:00 2006 +0000 | ||||||
|  |  | ||||||
|     Merge branch 'side' |     Merge branch 'side' | ||||||
|  |  | ||||||
|  | diff --git a/dir/sub b/dir/sub | ||||||
|  | index cead32e..992913c 100644 | ||||||
|  | --- a/dir/sub | ||||||
|  | +++ b/dir/sub | ||||||
|  | @@ -4,3 +4,5 @@ C | ||||||
|  |  D | ||||||
|  |  E | ||||||
|  |  F | ||||||
|  | +1 | ||||||
|  | +2 | ||||||
|  | diff --git a/file0 b/file0 | ||||||
|  | index b414108..10a8a9f 100644 | ||||||
|  | --- a/file0 | ||||||
|  | +++ b/file0 | ||||||
|  | @@ -4,3 +4,6 @@ | ||||||
|  |  4 | ||||||
|  |  5 | ||||||
|  |  6 | ||||||
|  | +A | ||||||
|  | +B | ||||||
|  | +C | ||||||
|  |  | ||||||
| commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 | commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 | ||||||
| Author: A U Thor <author@example.com> | Author: A U Thor <author@example.com> | ||||||
| Date:   Mon Jun 26 00:02:00 2006 +0000 | Date:   Mon Jun 26 00:02:00 2006 +0000 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Junio C Hamano
						Junio C Hamano