{"thread":{"id":"55982","subject":"[PATCH v2 0/4] Generic conflict style fixes","startedAt":"2021-06-22T00:27:19Z","lastAt":"2021-06-22T00:27:26Z","messageCount":5,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":2,"patchTotal":4},"messages":[{"id":"428149","messageId":"20210622002714.1720891-1-felipe.contreras@gmail.com","threadId":"55982","inReplyTo":null,"subject":"[PATCH v2 0/4] Generic conflict style fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-22T00:27:10Z","receivedAt":"2021-06-22T00:27:19Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The switch to diff3 by default got stuck on a tar pit, however that's no\nreason not to improve the merge.conflictStyle handling.\n\nI dropped all the controversial changes and focused only on the obvious\nimprovements.\n\nI switched to from the custom fill function to test_write_lines as Eric\nSunshine suggested, and used a simpler and stricter grep regex for diff3\nmarkers as Phillip Wood prompted.\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 v1:\n1:  118388c313 ! 1:  51351f1a77 test: add merge style config test\n    @@ t/t6440-config-conflict-markers.sh (new)\n     +\n     +. ./test-lib.sh\n     +\n    -+fill () {\n    -+\tfor i\n    -+\tdo\n    -+\t\techo \"$i\"\n    -+\tdone\n    -+}\n    -+\n     +test_expect_success 'merge' '\n     +\ttest_create_repo merge &&\n     +\t(\n     +\t\tcd merge &&\n     +\n    -+\t\tfill 1 2 3 >content &&\n    ++\t\ttest_write_lines 1 2 3 >content &&\n     +\t\tgit add content &&\n     +\t\tgit commit -m base &&\n     +\n    @@ t/t6440-config-conflict-markers.sh (new)\n     +\t\tgit commit -a -m left &&\n     +\n     +\t\ttest_must_fail git merge r &&\n    -+\t\t! grep -E \"\\|+\" content &&\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 -E \"\\|+\" content &&\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 -E \"\\|+\" content\n    ++\t\t! grep \"^|||||||\" content\n     +\t)\n     +'\n     +\n2:  697f2a2a5c ! 2:  1fccf561ed merge-tree: fix merge.conflictstyle handling\n    @@ t/t6440-config-conflict-markers.sh: test_expect_success 'merge' '\n     +\t\ttest_commit l content l &&\n     +\n     +\t\tgit merge-tree initial r l >actual &&\n    -+\t\t! grep -E \"\\|+\" actual &&\n    ++\t\t! grep \"^+|||||||\" content &&\n     +\n     +\t\tgit -c merge.conflictstyle=diff3 merge-tree initial r l >actual &&\n    -+\t\tgrep -E \"\\|+\" actual &&\n    ++\t\tgrep \"^+|||||||\" actual &&\n     +\n     +\t\tgit -c merge.conflictstyle=merge merge-tree initial r l >actual &&\n    -+\t\t! grep -E \"\\|+\" actual\n    ++\t\t! grep \"^+|||||||\" content\n     +\t)\n     +'\n     +\n3:  56a20f41a4 ! 3:  3bb872e3cd notes: fix merge.conflictstyle handling\n    @@ t/t6440-config-conflict-markers.sh: test_expect_success 'merge-tree' '\n     +\t\tgit notes add -f -m l initial &&\n     +\n     +\t\ttest_must_fail git notes merge r &&\n    -+\t\t! grep -E \"\\|+\" .git/NOTES_MERGE_WORKTREE/* &&\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 -E \"\\|+\" .git/NOTES_MERGE_WORKTREE/* &&\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 -E \"\\|+\" .git/NOTES_MERGE_WORKTREE/*\n    ++\t\t! grep \"^|||||||\" .git/NOTES_MERGE_WORKTREE/*\n     +\t)\n     +'\n     +\n4:  adce598754 < -:  ---------- checkout: fix merge.conflictstyle handling\n5:  a4ddbbc44a < -:  ---------- xdiff: rename XDL_MERGE_STYLE_DIFF3\n6:  c3e0940dab < -:  ---------- xdiff: simplify style assignments\n7:  6415e53345 < -:  ---------- xdiff: make diff3 the default conflictStyle\n-:  ---------- > 4:  a767bc68e6 test: document broken merge.conflictStyle handling\n-- \n2.32.0\n\n"},{"id":"428150","messageId":"20210622002714.1720891-2-felipe.contreras@gmail.com","threadId":"55982","inReplyTo":"20210622002714.1720891-1-felipe.contreras@gmail.com","subject":"[PATCH v2 1/4] test: add merge style config test","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-22T00:27:11Z","receivedAt":"2021-06-22T00:27:22Z","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.32.0\n\n"},{"id":"428151","messageId":"20210622002714.1720891-3-felipe.contreras@gmail.com","threadId":"55982","inReplyTo":"20210622002714.1720891-1-felipe.contreras@gmail.com","subject":"[PATCH v2 2/4] merge-tree: fix merge.conflictstyle handling","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-22T00:27:12Z","receivedAt":"2021-06-22T00:27:23Z","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 de8520778d..7d677bd75c 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -7,6 +7,8 @@\n #include \"blob.h\"\n #include \"exec-cmd.h\"\n #include \"merge-blobs.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 \n@@ -378,6 +380,8 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)\n \tif (argc != 4)\n \t\tusage(merge_tree_usage);\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]);\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.32.0\n\n"},{"id":"428152","messageId":"20210622002714.1720891-5-felipe.contreras@gmail.com","threadId":"55982","inReplyTo":"20210622002714.1720891-1-felipe.contreras@gmail.com","subject":"[PATCH v2 4/4] test: document broken merge.conflictStyle handling","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-22T00:27:14Z","receivedAt":"2021-06-22T00:27:26Z","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.32.0\n\n"},{"id":"428153","messageId":"20210622002714.1720891-4-felipe.contreras@gmail.com","threadId":"55982","inReplyTo":"20210622002714.1720891-1-felipe.contreras@gmail.com","subject":"[PATCH v2 3/4] notes: fix merge.conflictstyle handling","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-22T00:27:13Z","receivedAt":"2021-06-22T00:27:26Z","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 74bba39ca8..a333cc68ec 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -23,6 +23,7 @@\n #include \"notes-merge.h\"\n #include \"notes-utils.h\"\n #include \"worktree.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@@ -1000,7 +1001,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_STOP_AT_NON_OPTION);\n \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.32.0\n\n"}]}