{"thread":{"id":"24352","subject":"[PATCH 0/2] merge-tree: fix (merge-base a b) b a","startedAt":"2010-07-10T00:53:49Z","lastAt":"2010-07-10T00:53:51Z","messageCount":3,"participants":["Will Palmer"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"145253","messageId":"1278723231-24802-1-git-send-email-wmpalmer@gmail.com","threadId":"24352","inReplyTo":null,"subject":"[PATCH 0/2] merge-tree: fix (merge-base a b) b a","fromName":"Will Palmer","fromEmail":"wmpalmer@gmail.com","sentAt":"2010-07-10T00:53:49Z","receivedAt":"2010-07-10T00:53:49Z","isPatch":true,"sender":{"key":"wmpalmer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/357044?v=4"},"body":"This series notes, then fixes, a regression introduced by\n15b4f7a68d8c3c8ee28424415b203f61202d65d1 /\n\tmerge-tree: use ll_merge() not xdl_merge()\n\nI don't know the proper terminology to describe what's being fixed here.\nThis seems to most-easily be triggered by (for example):\n\tgit merge-tree $(git merge-base HEAD @{u}) HEAD @{u}\n\nIn the git repository at the moment, this could be triggered with:\n\tgit merge-tree $(git merge-base origin/next origin/master) \\\n\t\torigin/next origin/master\n\nThough as I write this, next has only just been merged with master, so\nthat is not the case. For an example which is less likely to go away,\ntry:\n\tgit merge-tree c9eaaab4165d8f402930d12899ec097495b599e6 \\\n\t\tbe16ac8cc8ce693c6adf37b80db65d10a41b4eb9 \\\n\t\t9918285fb10d81af9021dae99c5f4de88ded497c\n\nIt's actually very trivial to reproduce this, to the point where I\ncan't help but wonder how much merge-tree is actually being used. As\nI narrowed the test-case more and more, I was surprised by how little\nit took to trigger it. The first patch in this series includes some\nvery basic tests for merge-tree, the last of which demonstrates the\nregression.\n\nThe second patch implements the trivial fix for it.\n\nWill Palmer (2):\n  add basic tests for merge-tree\n  fix merge-tree where two branches share no changes\n\n builtin/merge-tree.c  |    3 ++-\n t/t4300-merge-tree.sh |   43 +++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 45 insertions(+), 1 deletions(-)\n create mode 100755 t/t4300-merge-tree.sh\n\n-- \n1.7.1.703.g42c01\n"},{"id":"145254","messageId":"1278723231-24802-2-git-send-email-wmpalmer@gmail.com","threadId":"24352","inReplyTo":"1278723231-24802-1-git-send-email-wmpalmer@gmail.com","subject":"[PATCH 1/2] add basic tests for merge-tree","fromName":"Will Palmer","fromEmail":"wmpalmer@gmail.com","sentAt":"2010-07-10T00:53:50Z","receivedAt":"2010-07-10T00:53:50Z","isPatch":true,"sender":{"key":"wmpalmer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/357044?v=4"},"body":"merge-tree had no test cases, so here we add some very basic tests for\nit, including one known-breakage.\n\nSigned-off-by: Will Palmer <wmpalmer@gmail.com>\n---\n t/t4300-merge-tree.sh |   43 +++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 43 insertions(+), 0 deletions(-)\n create mode 100755 t/t4300-merge-tree.sh\n\ndiff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh\nnew file mode 100755\nindex 0000000..afcb89d\n--- /dev/null\n+++ b/t/t4300-merge-tree.sh\n@@ -0,0 +1,43 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Will Palmer\n+#\n+\n+test_description='git merge-tree'\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\ttest_commit \"initial\"\n+'\n+\n+test_expect_success 'both added same' '\n+\tgit reset --hard initial\n+\ttest_commit \"same-A\" \"ONE\" \"AAA\" \n+\n+\tgit reset --hard initial\n+\ttest_commit \"same-B\" \"ONE\" \"AAA\"\n+\n+\tgit merge-tree initial same-A same-B\n+'\n+\n+test_expect_success 'both added conflict' '\n+\tgit reset --hard initial\n+\ttest_commit \"diff-A\" \"ONE\" \"AAA\" \n+\n+\tgit reset --hard initial\n+\ttest_commit \"diff-B\" \"ONE\" \"BBB\"\n+\n+\tgit merge-tree initial diff-A diff-B\n+'\n+\n+test_expect_failure 'nothing similar' '\n+\tgit reset --hard initial\n+\ttest_commit \"no-common-A\" \"ONE\" \"AAA\" \n+\n+\tgit reset --hard initial\n+\ttest_commit \"no-common-B\" \"TWO\" \"BBB\"\n+\n+\tgit merge-tree initial no-common-A no-common-B\n+'\n+\n+test_done\n-- \n1.7.1.703.g42c01\n"},{"id":"145255","messageId":"1278723231-24802-3-git-send-email-wmpalmer@gmail.com","threadId":"24352","inReplyTo":"1278723231-24802-1-git-send-email-wmpalmer@gmail.com","subject":"[PATCH 2/2] fix merge-tree where two branches share no changes","fromName":"Will Palmer","fromEmail":"wmpalmer@gmail.com","sentAt":"2010-07-10T00:53:51Z","receivedAt":"2010-07-10T00:53:51Z","isPatch":true,"sender":{"key":"wmpalmer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/357044?v=4"},"body":"Here we fix a regression which was introduced by\n15b4f7a68d8c3c8ee28424415b203f61202d65d1 /\n\tmerge-tree: use ll_merge() not xdl_merge()\n\nWhich caused merge-tree to segfault in particular combinations of\nmerging files which existed in one branch, but not in the other or in\nthe merge-base. This was caused by referencing entry->path at a time\nwhen entry was known to be possibly-NULL.\n\nTo correct the problem, we save the path of the entry we came in with,\nas the path should be the same among all the stages no matter which\nsides are involved in the merge.\n\nSigned-off-by: Will Palmer <wmpalmer@gmail.com>\n---\n builtin/merge-tree.c  |    3 ++-\n t/t4300-merge-tree.sh |    2 +-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex fc00d79..9b25ddc 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -60,6 +60,7 @@ static void *result(struct merge_list *entry, unsigned long *size)\n {\n \tenum object_type type;\n \tstruct blob *base, *our, *their;\n+\tconst char *path = entry->path;\n \n \tif (!entry->stage)\n \t\treturn read_sha1_file(entry->blob->object.sha1, &type, size);\n@@ -76,7 +77,7 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \ttheir = NULL;\n \tif (entry)\n \t\ttheir = entry->blob;\n-\treturn merge_file(entry->path, base, our, their, size);\n+\treturn merge_file(path, base, our, their, size);\n }\n \n static void *origin(struct merge_list *entry, unsigned long *size)\ndiff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh\nindex afcb89d..97a3deb 100755\n--- a/t/t4300-merge-tree.sh\n+++ b/t/t4300-merge-tree.sh\n@@ -30,7 +30,7 @@ test_expect_success 'both added conflict' '\n \tgit merge-tree initial diff-A diff-B\n '\n \n-test_expect_failure 'nothing similar' '\n+test_expect_success 'nothing similar' '\n \tgit reset --hard initial\n \ttest_commit \"no-common-A\" \"ONE\" \"AAA\" \n \n-- \n1.7.1.703.g42c01\n"}]}