{"thread":{"id":"59726","subject":"[PATCH v3 0/4] Generic conflict style fixes","startedAt":"2023-05-10T21:37:46Z","lastAt":"2023-05-10T21:37:56Z","messageCount":5,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":3,"patchTotal":4},"messages":[{"id":"476992","messageId":"20230510213738.505241-1-felipe.contreras@gmail.com","threadId":"59726","inReplyTo":null,"subject":"[PATCH v3 0/4] Generic conflict style fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2023-05-10T21:37:34Z","receivedAt":"2023-05-10T21:37:46Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"I sent v2 of this series almost 2 years ago [1] and received zero\nfeedback. This is the same version except rebased on top of master.\n\nIn v1 the idea was to change the default conflictstyle, but that\nproposal got stuck due to a variety of reasons (including unnecessary\npersonal drama).\n\nv2 should not have been controversial, and neither is v3.\n\n[1] https://lore.kernel.org/git/20210622002714.1720891-1-felipe.contreras@gmail.com/\n\nFelipe Contreras (4):\n  test: add merge style config test\n  merge-tree: fix merge.conflictstyle handling\n  notes: fix merge.conflictstyle handling\n  test: document broken merge.conflictStyle handling\n\n builtin/merge-tree.c               |   4 +\n builtin/notes.c                    |   3 +-\n t/t6440-config-conflict-markers.sh | 116 +++++++++++++++++++++++++++++\n 3 files changed, 122 insertions(+), 1 deletion(-)\n create mode 100755 t/t6440-config-conflict-markers.sh\n\nRange-diff against v2:\n1:  51351f1a77 = 1:  6867f22f49 test: add merge style config test\n2:  1fccf561ed ! 2:  60bf233000 merge-tree: fix merge.conflictstyle handling\n    @@ Commit message\n     \n      ## builtin/merge-tree.c ##\n     @@\n    - #include \"blob.h\"\n    - #include \"exec-cmd.h\"\n      #include \"merge-blobs.h\"\n    + #include \"quote.h\"\n    + #include \"tree.h\"\n     +#include \"config.h\"\n     +#include \"xdiff-interface.h\"\n      \n    - static const char merge_tree_usage[] = \"git merge-tree <base-tree> <branch1> <branch2>\";\n    + static int line_termination = '\\n';\n      \n     @@ builtin/merge-tree.c: int cmd_merge_tree(int argc, const char **argv, const char *prefix)\n    - \tif (argc != 4)\n    - \t\tusage(merge_tree_usage);\n    + \tif (argc != expected_remaining_argc)\n    + \t\tusage_with_options(merge_tree_usage, mt_options);\n      \n     +\tgit_config(git_xmerge_config, NULL);\n     +\n    - \tbuf1 = get_tree_descriptor(r, t+0, argv[1]);\n    - \tbuf2 = get_tree_descriptor(r, t+1, argv[2]);\n    - \tbuf3 = get_tree_descriptor(r, t+2, argv[3]);\n    + \t/* Do the relevant type of merge */\n    + \tif (o.mode == MODE_REAL)\n    + \t\treturn real_merge(&o, merge_base, argv[0], argv[1], prefix);\n     \n      ## t/t6440-config-conflict-markers.sh ##\n     @@ t/t6440-config-conflict-markers.sh: test_expect_success 'merge' '\n3:  3bb872e3cd ! 3:  cf8cabaae3 notes: fix merge.conflictstyle handling\n    @@ Commit message\n     \n      ## builtin/notes.c ##\n     @@\n    - #include \"notes-merge.h\"\n      #include \"notes-utils.h\"\n      #include \"worktree.h\"\n    + #include \"write-or-die.h\"\n     +#include \"xdiff-interface.h\"\n      \n      static const char * const git_notes_usage[] = {\n    @@ builtin/notes.c: int cmd_notes(int argc, const char **argv, const char *prefix)\n     -\tgit_config(git_default_config, NULL);\n     +\tgit_config(git_xmerge_config, NULL);\n      \targc = parse_options(argc, argv, prefix, options, git_notes_usage,\n    - \t\t\t     PARSE_OPT_STOP_AT_NON_OPTION);\n    - \n    + \t\t\t     PARSE_OPT_SUBCOMMAND_OPTIONAL);\n    + \tif (!fn) {\n     \n      ## t/t6440-config-conflict-markers.sh ##\n     @@ t/t6440-config-conflict-markers.sh: test_expect_success 'merge-tree' '\n4:  a767bc68e6 = 4:  5959fea3c4 test: document broken merge.conflictStyle handling\n-- \n2.40.0+fc1\n\n"},{"id":"476993","messageId":"20230510213738.505241-2-felipe.contreras@gmail.com","threadId":"59726","inReplyTo":"20230510213738.505241-1-felipe.contreras@gmail.com","subject":"[PATCH v3 1/4] test: add merge style config test","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2023-05-10T21:37:35Z","receivedAt":"2023-05-10T21:37:47Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We want to test different combinations of merge.conflictstyle, and a new\nfile is the best place to do that.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t6440-config-conflict-markers.sh | 37 ++++++++++++++++++++++++++++++\n 1 file changed, 37 insertions(+)\n create mode 100755 t/t6440-config-conflict-markers.sh\n\ndiff --git a/t/t6440-config-conflict-markers.sh b/t/t6440-config-conflict-markers.sh\nnew file mode 100755\nindex 0000000000..813d7dda9a\n--- /dev/null\n+++ b/t/t6440-config-conflict-markers.sh\n@@ -0,0 +1,37 @@\n+#!/bin/sh\n+\n+test_description='merge style conflict markers configurations'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'merge' '\n+\ttest_create_repo merge &&\n+\t(\n+\t\tcd merge &&\n+\n+\t\ttest_write_lines 1 2 3 >content &&\n+\t\tgit add content &&\n+\t\tgit commit -m base &&\n+\n+\t\tgit checkout -b r &&\n+\t\techo six >>content &&\n+\t\tgit commit -a -m right &&\n+\n+\t\tgit checkout master &&\n+\t\techo 7 >>content &&\n+\t\tgit commit -a -m left &&\n+\n+\t\ttest_must_fail git merge r &&\n+\t\t! grep \"^|||||||\" content &&\n+\n+\t\tgit reset --hard &&\n+\t\ttest_must_fail git -c merge.conflictstyle=diff3 merge r &&\n+\t\tgrep \"^|||||||\" content &&\n+\n+\t\tgit reset --hard &&\n+\t\ttest_must_fail git -c merge.conflictstyle=merge merge r &&\n+\t\t! grep \"^|||||||\" content\n+\t)\n+'\n+\n+test_done\n-- \n2.40.0+fc1\n\n"},{"id":"476994","messageId":"20230510213738.505241-3-felipe.contreras@gmail.com","threadId":"59726","inReplyTo":"20230510213738.505241-1-felipe.contreras@gmail.com","subject":"[PATCH v3 2/4] merge-tree: fix merge.conflictstyle handling","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2023-05-10T21:37:36Z","receivedAt":"2023-05-10T21:37:52Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Currently it's completely ignored.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/merge-tree.c               |  4 ++++\n t/t6440-config-conflict-markers.sh | 21 +++++++++++++++++++++\n 2 files changed, 25 insertions(+)\n\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex aa8040c2a6..a98f84634e 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -17,6 +17,8 @@\n #include \"merge-blobs.h\"\n #include \"quote.h\"\n #include \"tree.h\"\n+#include \"config.h\"\n+#include \"xdiff-interface.h\"\n \n static int line_termination = '\\n';\n \n@@ -628,6 +630,8 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)\n \tif (argc != expected_remaining_argc)\n \t\tusage_with_options(merge_tree_usage, mt_options);\n \n+\tgit_config(git_xmerge_config, NULL);\n+\n \t/* Do the relevant type of merge */\n \tif (o.mode == MODE_REAL)\n \t\treturn real_merge(&o, merge_base, argv[0], argv[1], prefix);\ndiff --git a/t/t6440-config-conflict-markers.sh b/t/t6440-config-conflict-markers.sh\nindex 813d7dda9a..cb2ee3ad0a 100755\n--- a/t/t6440-config-conflict-markers.sh\n+++ b/t/t6440-config-conflict-markers.sh\n@@ -34,4 +34,25 @@ test_expect_success 'merge' '\n \t)\n '\n \n+test_expect_success 'merge-tree' '\n+\ttest_create_repo merge-tree &&\n+\t(\n+\t\tcd merge-tree &&\n+\n+\t\ttest_commit initial initial-file initial &&\n+\t\ttest_commit r content r &&\n+\t\tgit reset --hard initial &&\n+\t\ttest_commit l content l &&\n+\n+\t\tgit merge-tree initial r l >actual &&\n+\t\t! grep \"^+|||||||\" content &&\n+\n+\t\tgit -c merge.conflictstyle=diff3 merge-tree initial r l >actual &&\n+\t\tgrep \"^+|||||||\" actual &&\n+\n+\t\tgit -c merge.conflictstyle=merge merge-tree initial r l >actual &&\n+\t\t! grep \"^+|||||||\" content\n+\t)\n+'\n+\n test_done\n-- \n2.40.0+fc1\n\n"},{"id":"476995","messageId":"20230510213738.505241-5-felipe.contreras@gmail.com","threadId":"59726","inReplyTo":"20230510213738.505241-1-felipe.contreras@gmail.com","subject":"[PATCH v3 4/4] test: document broken merge.conflictStyle handling","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2023-05-10T21:37:38Z","receivedAt":"2023-05-10T21:37:54Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Currently both merge.conflictStyle and --conflict=diff3 don't work\ntogether for `git commit --merge`, since the former wrongly overrides\nthe later.\n\nThere is no easy way to fix this, so mark it as broken for now.\n\nSignee-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t6440-config-conflict-markers.sh | 31 ++++++++++++++++++++++++++++++\n 1 file changed, 31 insertions(+)\n\ndiff --git a/t/t6440-config-conflict-markers.sh b/t/t6440-config-conflict-markers.sh\nindex c51512ced6..3ba993a6a8 100755\n--- a/t/t6440-config-conflict-markers.sh\n+++ b/t/t6440-config-conflict-markers.sh\n@@ -82,4 +82,35 @@ test_expect_success 'notes' '\n \t)\n '\n \n+test_expect_failure 'checkout' '\n+\ttest_create_repo checkout &&\n+\t(\n+\t\ttest_commit checkout &&\n+\n+\t\ttest_write_lines a b c d e >content &&\n+\t\tgit add content &&\n+\t\tgit commit -m initial &&\n+\n+\t\tgit checkout -b simple master &&\n+\t\ttest_write_lines a c e >content &&\n+\t\tgit commit -a -m simple &&\n+\n+\t\ttest_write_lines b d >content &&\n+\t\tgit checkout --merge master &&\n+\t\t! grep \"^|||||||\" content &&\n+\n+\t\tgit config merge.conflictstyle merge &&\n+\n+\t\tgit checkout -f simple &&\n+\t\ttest_write_lines b d >content &&\n+\t\tgit checkout --merge --conflict=diff3 master &&\n+\t\tgrep \"^|||||||\" content &&\n+\n+\t\tgit checkout -f simple &&\n+\t\ttest_write_lines b d >content &&\n+\t\tgit checkout --merge --conflict=merge master &&\n+\t\t! grep \"^|||||||\" content\n+\t)\n+'\n+\n test_done\n-- \n2.40.0+fc1\n\n"},{"id":"476996","messageId":"20230510213738.505241-4-felipe.contreras@gmail.com","threadId":"59726","inReplyTo":"20230510213738.505241-1-felipe.contreras@gmail.com","subject":"[PATCH v3 3/4] notes: fix merge.conflictstyle handling","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2023-05-10T21:37:37Z","receivedAt":"2023-05-10T21:37:56Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Currently it's completely ignored.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/notes.c                    |  3 ++-\n t/t6440-config-conflict-markers.sh | 27 +++++++++++++++++++++++++++\n 2 files changed, 29 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex d5788352b6..9a9044b50b 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -28,6 +28,7 @@\n #include \"notes-utils.h\"\n #include \"worktree.h\"\n #include \"write-or-die.h\"\n+#include \"xdiff-interface.h\"\n \n static const char * const git_notes_usage[] = {\n \tN_(\"git notes [--ref <notes-ref>] [list [<object>]]\"),\n@@ -1020,7 +1021,7 @@ int cmd_notes(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \n-\tgit_config(git_default_config, NULL);\n+\tgit_config(git_xmerge_config, NULL);\n \targc = parse_options(argc, argv, prefix, options, git_notes_usage,\n \t\t\t     PARSE_OPT_SUBCOMMAND_OPTIONAL);\n \tif (!fn) {\ndiff --git a/t/t6440-config-conflict-markers.sh b/t/t6440-config-conflict-markers.sh\nindex cb2ee3ad0a..c51512ced6 100755\n--- a/t/t6440-config-conflict-markers.sh\n+++ b/t/t6440-config-conflict-markers.sh\n@@ -55,4 +55,31 @@ test_expect_success 'merge-tree' '\n \t)\n '\n \n+test_expect_success 'notes' '\n+\ttest_create_repo notes &&\n+\t(\n+\t\ttest_commit initial &&\n+\n+\t\tgit -c core.notesRef=refs/notes/b notes add -m b initial &&\n+\n+\t\tgit update-ref refs/notes/r refs/notes/b &&\n+\t\tgit -c core.notesRef=refs/notes/r notes add -f -m r initial &&\n+\n+\t\tgit update-ref refs/notes/l refs/notes/b &&\n+\t\tgit config core.notesRef refs/notes/l &&\n+\t\tgit notes add -f -m l initial &&\n+\n+\t\ttest_must_fail git notes merge r &&\n+\t\t! grep \"^|||||||\" .git/NOTES_MERGE_WORKTREE/* &&\n+\n+\t\tgit notes merge --abort &&\n+\t\ttest_must_fail git -c merge.conflictstyle=diff3 notes merge r &&\n+\t\tgrep \"^|||||||\" .git/NOTES_MERGE_WORKTREE/* &&\n+\n+\t\tgit notes merge --abort &&\n+\t\ttest_must_fail git -c merge.conflictstyle=merge notes merge r &&\n+\t\t! grep \"^|||||||\" .git/NOTES_MERGE_WORKTREE/*\n+\t)\n+'\n+\n test_done\n-- \n2.40.0+fc1\n\n"}]}