[PATCH v2] Demonstrate bugs when a directory is replaced with a symlink
- From
- Pickens, James E <james.e.pickens@intel.com>
- Date
- Jul 29, 2009, 17:48 UTC
- Message-ID
- <3BA20DF9B35F384F8B7395B001EC3FB342402AD9@azsmsx507.amr.corp.intel.com>
- In-Reply-To
- <7v4osvyjl2.fsf@alter.siamese.dyndns.org>
This test creates two directories, a/b and a/b-2, then replaces a/b with a symlink to a/b-2, then merges that change into another branch that contains an unrelated change.
There are two bugs: 1. 'git checkout' wrongly deletes work tree file a/b-2/d. 2. 'git merge' wrongly deletes work tree file a/b-2/d.
The test goes on to create another branch in which a/b-2 is replaced with a symlink to a/b (i.e., the reverse of what was done the first time), and merge it with the "unrelated changes" branch.
There's another bug: 3. Since the changes are unrelated, the merge should be clean, but git reports a conflict.
Note that using the resolve strategy instead of recursive makes the second bug go away, but not the third one.
Signed-off-by: James Pickens <james.e.pickens@intel.com> --- This version combines the two tests into one, and cleans up between steps so that the early failures don't affect the later tests.
This time I include the bare minimum commands inside the test_expect_failure calls, which seems like the right thing to do, since the other commands are expected to "succeed" (exit code of 0).
BTW I'm sending this patch using 'git format-patch' + Outlook instead of 'git send-email'; apologies if it gets botched.
t/t6035-merge-dir-to-symlink.sh | 49 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-) create mode 100755 t/t6035-merge-dir-to-symlink.sh
diff --git a/t/t6035-merge-dir-to-symlink.sh b/t/t6035-merge-dir-to-symlink.sh new file mode 100755 index 0000000..94a9f32 --- /dev/null +++ b/t/t6035-merge-dir-to-symlink.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +test_description='merging when a directory was replaced with a symlink' +. ./test-lib.sh + +test_expect_success 'setup a merge where dir a/b changed to symlink' ' + mkdir -p a/b/c a/b-2/c && + > a/b/c/d && + > a/b-2/c/d && + > a/x && + git add -A && + git commit -m base && + rm -rf a/b && + ln -s b-2 a/b && + git add -A && + git commit -m "dir to symlink" && + git checkout -b temp HEAD^ +' + +test_expect_failure 'checkout should not have deleted a/b-2/c/d' ' + test -f a/b-2/c/d +' + +test_expect_success 'clean the work tree and do the merge' ' + git reset --hard && + test -f a/b-2/c/d && + echo x > a/x && + git add a/x && + git commit -m x && + git merge master +' + +test_expect_failure 'merge should not have deleted a/b-2/c/d' ' + test -f a/b-2/c/d +' + +test_expect_success 'setup a merge where dir a/b-2 changed to symlink' ' + git checkout -f -b temp2 master^ && + rm -rf a/b-2 && + ln -s b a/b-2 && + git add -A && + git commit -m "dir a/b-2 to symlink" +' + +test_expect_failure 'merge should not have conflicts' ' + git merge temp +' + +test_done -- 1.6.2.5