Junio C Hamano <gits...@pobox.com> writes:

> The latter was inspired by a recent discussion, most notably
>
>    http://thread.gmane.org/gmane.comp.version-control.git/273937/focus=273988
>
> but implements it with a much less UI impact.  Tweaking "git log -p"
> has a lot of fallout---interested parties can try it out and how two
> tests in t4xxx series break.

Just for the record, here is what I did before deciding that the
idea of turning '-p' into '--cc -m' is not good and instead did the
"'--cc' should show the patch without '-p' and '-m'" that is the
real [3/3].  The attached patch replaces 3/3, showss what happens if
you tweak 'log -p' to imply '-m --cc'"; the change of behaviours is
illustrated by the updated tests.

Many are good-looking, and some others are questionable.

 * "log -G<string> -p" and "log -S<string> -p" that silently turns
   "-p" into "-m --cc" shows merges that changed the occurrences of
   <string>, but if the merge is a trivial textual merge, the change
   itself is not seen (as we are doing "--cc").  This looks very
   questionable.

 * Similarly, "log -p --stat" shows the diffstat against the first
   parent for a merge but does not show the patch text, as "--cc" is
   in effect, for a trivial textual merge.  This looks strange.

 * Even though I very much do like the fact that we see _something_
   in the output for a merge commit, "log --patch-with-stat" that
   outputs a "patch" that cannot be grokked by "git apply" feels
   wrong.

All of the above led me to say "when the user explicitly asks --cc,
show the merges that way, otherwise keeping the 'merges are by
default ignored' is the right thing".


diff --git a/builtin/log.c b/builtin/log.c
index 519f170..1a77804 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -633,6 +633,14 @@ static void log_setup_revisions_tweak(struct rev_info *rev,
            rev->prune_data.nr == 1)
                DIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);
 
+       /* Turn -p without -m to --cc -p -m */
+       if (rev->ignore_merges && !rev->combine_merges &&
+           (rev->diffopt.output_format & DIFF_FORMAT_PATCH)) {
+               rev->ignore_merges = 0;
+               rev->combine_merges = 1;
+               rev->dense_combined_merges = 1;
+       }
+
        /* Turn --cc/-c into -p --cc/-c when -p was not given */
        if (!rev->diffopt.output_format && rev->combine_merges)
                rev->diffopt.output_format = DIFF_FORMAT_PATCH;
diff --git a/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ 
b/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_
index a18f147..04f4eee 100644
--- a/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_
+++ b/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_
@@ -6,6 +6,23 @@ Date:   Mon Jun 26 00:04:00 2006 +0000
 
     Merge branch 'side'
 
+ dir/sub | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --cc dir/sub
+index cead32e,7289e35..992913c
+--- a/dir/sub
++++ b/dir/sub
+@@@ -1,6 -1,4 +1,8 @@@
+  A
+  B
+ +C
+ +D
+ +E
+ +F
++ 1
++ 2
+
 commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
 Author: A U Thor <aut...@example.com>
 Date:   Mon Jun 26 00:03:00 2006 +0000
diff --git a/t/t4013/diff.log_--patch-with-stat_master 
b/t/t4013/diff.log_--patch-with-stat_master
index ae425c4..ec4b1b9 100644
--- a/t/t4013/diff.log_--patch-with-stat_master
+++ b/t/t4013/diff.log_--patch-with-stat_master
@@ -6,6 +6,38 @@ Date:   Mon Jun 26 00:04:00 2006 +0000
 
     Merge branch 'side'
 
+ dir/sub | 2 ++
+ file0   | 3 +++
+ 2 files changed, 5 insertions(+)
+
+diff --cc dir/sub
+index cead32e,7289e35..992913c
+--- a/dir/sub
++++ b/dir/sub
+@@@ -1,6 -1,4 +1,8 @@@
+  A
+  B
+ +C
+ +D
+ +E
+ +F
++ 1
++ 2
+diff --cc file0
+index b414108,f4615da..10a8a9f
+--- a/file0
++++ b/file0
+@@@ -1,6 -1,6 +1,9 @@@
+  1
+  2
+  3
+ +4
+ +5
+ +6
++ A
++ B
++ C
+
 commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
 Author: A U Thor <aut...@example.com>
 Date:   Mon Jun 26 00:03:00 2006 +0000
diff --git a/t/t4013/diff.log_--patch-with-stat_master_--_dir_ 
b/t/t4013/diff.log_--patch-with-stat_master_--_dir_
index d5207ca..d3be9a2 100644
--- a/t/t4013/diff.log_--patch-with-stat_master_--_dir_
+++ b/t/t4013/diff.log_--patch-with-stat_master_--_dir_
@@ -6,6 +6,23 @@ Date:   Mon Jun 26 00:04:00 2006 +0000
 
     Merge branch 'side'
 
+ dir/sub | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --cc dir/sub
+index cead32e,7289e35..992913c
+--- a/dir/sub
++++ b/dir/sub
+@@@ -1,6 -1,4 +1,8 @@@
+  A
+  B
+ +C
+ +D
+ +E
+ +F
++ 1
++ 2
+
 commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
 Author: A U Thor <aut...@example.com>
 Date:   Mon Jun 26 00:03:00 2006 +0000
diff --git a/t/t4013/diff.log_--root_--patch-with-stat_--summary_master 
b/t/t4013/diff.log_--root_--patch-with-stat_--summary_master
index dffc09d..a6aa60a 100644
--- a/t/t4013/diff.log_--root_--patch-with-stat_--summary_master
+++ b/t/t4013/diff.log_--root_--patch-with-stat_--summary_master
@@ -6,6 +6,38 @@ Date:   Mon Jun 26 00:04:00 2006 +0000
 
     Merge branch 'side'
 
+ dir/sub | 2 ++
+ file0   | 3 +++
+ 2 files changed, 5 insertions(+)
+
+diff --cc dir/sub
+index cead32e,7289e35..992913c
+--- a/dir/sub
++++ b/dir/sub
+@@@ -1,6 -1,4 +1,8 @@@
+  A
+  B
+ +C
+ +D
+ +E
+ +F
++ 1
++ 2
+diff --cc file0
+index b414108,f4615da..10a8a9f
+--- a/file0
++++ b/file0
+@@@ -1,6 -1,6 +1,9 @@@
+  1
+  2
+  3
+ +4
+ +5
+ +6
++ A
++ B
++ C
+
 commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
 Author: A U Thor <aut...@example.com>
 Date:   Mon Jun 26 00:03:00 2006 +0000
diff --git a/t/t4013/diff.log_--root_--patch-with-stat_master 
b/t/t4013/diff.log_--root_--patch-with-stat_master
index 55aa980..4d0ff3d 100644
--- a/t/t4013/diff.log_--root_--patch-with-stat_master
+++ b/t/t4013/diff.log_--root_--patch-with-stat_master
@@ -6,6 +6,38 @@ Date:   Mon Jun 26 00:04:00 2006 +0000
 
     Merge branch 'side'
 
+ dir/sub | 2 ++
+ file0   | 3 +++
+ 2 files changed, 5 insertions(+)
+
+diff --cc dir/sub
+index cead32e,7289e35..992913c
+--- a/dir/sub
++++ b/dir/sub
+@@@ -1,6 -1,4 +1,8 @@@
+  A
+  B
+ +C
+ +D
+ +E
+ +F
++ 1
++ 2
+diff --cc file0
+index b414108,f4615da..10a8a9f
+--- a/file0
++++ b/file0
+@@@ -1,6 -1,6 +1,9 @@@
+  1
+  2
+  3
+ +4
+ +5
+ +6
++ A
++ B
++ C
+
 commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
 Author: A U Thor <aut...@example.com>
 Date:   Mon Jun 26 00:03:00 2006 +0000
diff --git a/t/t4013/diff.log_--root_-p_master 
b/t/t4013/diff.log_--root_-p_master
index b42c334..19dfc00 100644
--- a/t/t4013/diff.log_--root_-p_master
+++ b/t/t4013/diff.log_--root_-p_master
@@ -6,6 +6,34 @@ Date:   Mon Jun 26 00:04:00 2006 +0000
 
     Merge branch 'side'
 
+diff --cc dir/sub
+index cead32e,7289e35..992913c
+--- a/dir/sub
++++ b/dir/sub
+@@@ -1,6 -1,4 +1,8 @@@
+  A
+  B
+ +C
+ +D
+ +E
+ +F
++ 1
++ 2
+diff --cc file0
+index b414108,f4615da..10a8a9f
+--- a/file0
++++ b/file0
+@@@ -1,6 -1,6 +1,9 @@@
+  1
+  2
+  3
+ +4
+ +5
+ +6
++ A
++ B
++ C
+
 commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
 Author: A U Thor <aut...@example.com>
 Date:   Mon Jun 26 00:03:00 2006 +0000
diff --git a/t/t4013/diff.log_-GF_-p_--pickaxe-all_master 
b/t/t4013/diff.log_-GF_-p_--pickaxe-all_master
index d36f880..4b6b93a 100644
--- a/t/t4013/diff.log_-GF_-p_--pickaxe-all_master
+++ b/t/t4013/diff.log_-GF_-p_--pickaxe-all_master
@@ -1,4 +1,12 @@
 $ git log -GF -p --pickaxe-all master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <aut...@example.com>
+Date:   Mon Jun 26 00:04:00 2006 +0000
+
+    Merge branch 'side'
+
+
 commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
 Author: A U Thor <aut...@example.com>
 Date:   Mon Jun 26 00:02:00 2006 +0000
diff --git a/t/t4013/diff.log_-GF_-p_master b/t/t4013/diff.log_-GF_-p_master
index 9d93f2c..a712a5a 100644
--- a/t/t4013/diff.log_-GF_-p_master
+++ b/t/t4013/diff.log_-GF_-p_master
@@ -1,4 +1,12 @@
 $ git log -GF -p master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <aut...@example.com>
+Date:   Mon Jun 26 00:04:00 2006 +0000
+
+    Merge branch 'side'
+
+
 commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
 Author: A U Thor <aut...@example.com>
 Date:   Mon Jun 26 00:02:00 2006 +0000
diff --git a/t/t4013/diff.log_-SF_-p_master b/t/t4013/diff.log_-SF_-p_master
index 5e32438..56c0d52 100644
--- a/t/t4013/diff.log_-SF_-p_master
+++ b/t/t4013/diff.log_-SF_-p_master
@@ -1,4 +1,12 @@
 $ git log -SF -p master
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <aut...@example.com>
+Date:   Mon Jun 26 00:04:00 2006 +0000
+
+    Merge branch 'side'
+
+
 commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
 Author: A U Thor <aut...@example.com>
 Date:   Mon Jun 26 00:02:00 2006 +0000
diff --git a/t/t4013/diff.log_-p_--first-parent_master 
b/t/t4013/diff.log_-p_--first-parent_master
index 3fc896d..f5af0c6 100644
--- a/t/t4013/diff.log_-p_--first-parent_master
+++ b/t/t4013/diff.log_-p_--first-parent_master
@@ -6,6 +6,34 @@ Date:   Mon Jun 26 00:04:00 2006 +0000
 
     Merge branch 'side'
 
+diff --cc dir/sub
+index cead32e,7289e35..992913c
+--- a/dir/sub
++++ b/dir/sub
+@@@ -1,6 -1,4 +1,8 @@@
+  A
+  B
+ +C
+ +D
+ +E
+ +F
++ 1
++ 2
+diff --cc file0
+index b414108,f4615da..10a8a9f
+--- a/file0
++++ b/file0
+@@@ -1,6 -1,6 +1,9 @@@
+  1
+  2
+  3
+ +4
+ +5
+ +6
++ A
++ B
++ C
+
 commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
 Author: A U Thor <aut...@example.com>
 Date:   Mon Jun 26 00:02:00 2006 +0000
diff --git a/t/t4013/diff.log_-p_master b/t/t4013/diff.log_-p_master
index bf1326d..506947be 100644
--- a/t/t4013/diff.log_-p_master
+++ b/t/t4013/diff.log_-p_master
@@ -6,6 +6,34 @@ Date:   Mon Jun 26 00:04:00 2006 +0000
 
     Merge branch 'side'
 
+diff --cc dir/sub
+index cead32e,7289e35..992913c
+--- a/dir/sub
++++ b/dir/sub
+@@@ -1,6 -1,4 +1,8 @@@
+  A
+  B
+ +C
+ +D
+ +E
+ +F
++ 1
++ 2
+diff --cc file0
+index b414108,f4615da..10a8a9f
+--- a/file0
++++ b/file0
+@@@ -1,6 -1,6 +1,9 @@@
+  1
+  2
+  3
+ +4
+ +5
+ +6
++ A
++ B
++ C
+
 commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
 Author: A U Thor <aut...@example.com>
 Date:   Mon Jun 26 00:03:00 2006 +0000
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 35d2d7c..e950092 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -570,6 +570,9 @@ cat >expect <<\EOF
 | |
 | |     Merge HEADS DESCRIPTION
 | |
+| |  reach.t | 1 +
+| |  1 file changed, 1 insertion(+)
+| |
 | * commit COMMIT_OBJECT_NAME
 | | Author: A U Thor <aut...@example.com>
 | |
@@ -593,6 +596,10 @@ cat >expect <<\EOF
 | | | |
 | | | |     Merge HEADS DESCRIPTION
 | | | |
+| | | |  octopus-a.t | 1 +
+| | | |  octopus-b.t | 1 +
+| | | |  2 files changed, 2 insertions(+)
+| | | |
 | | * | commit COMMIT_OBJECT_NAME
 | | |/  Author: A U Thor <aut...@example.com>
 | | |
@@ -647,18 +654,30 @@ cat >expect <<\EOF
 | |
 | |     Merge branch 'tangle'
 | |
+| |  tangle-a | 1 +
+| |  1 file changed, 1 insertion(+)
+| |
 | *   commit COMMIT_OBJECT_NAME
 | |\  Merge: MERGE_PARENTS
 | | | Author: A U Thor <aut...@example.com>
 | | |
 | | |     Merge branch 'side' (early part) into tangle
 | | |
+| | |  1 | 1 +
+| | |  1 file changed, 1 insertion(+)
+| | |
 | * |   commit COMMIT_OBJECT_NAME
 | |\ \  Merge: MERGE_PARENTS
 | | | | Author: A U Thor <aut...@example.com>
 | | | |
 | | | |     Merge branch 'master' (early part) into tangle
 | | | |
+| | | |  a/two | 1 +
+| | | |  ein   | 1 +
+| | | |  ichi  | 1 +
+| | | |  one   | 1 -
+| | | |  4 files changed, 3 insertions(+), 1 deletion(-)
+| | | |
 | * | | commit COMMIT_OBJECT_NAME
 | | | | Author: A U Thor <aut...@example.com>
 | | | |
@@ -681,6 +700,10 @@ cat >expect <<\EOF
 | | | | |
 | | | | |     Merge branch 'side'
 | | | | |
+| | | | |  1 | 1 +
+| | | | |  2 | 1 +
+| | | | |  2 files changed, 2 insertions(+)
+| | | | |
 | * | | | commit COMMIT_OBJECT_NAME
 | | |_|/  Author: A U Thor <aut...@example.com>
 | |/| |



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to