git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] Demonstrate bugs when a directory is replaced with a symlink

From
PEPickens, 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
Previous: Pickens, James ENext: Junio C Hamano
Message 9 of 18 in “More symlink/directory troubles”
  1. James PickensJul 28, 2009
  2. 1/2 Demonstrate bugs when a directory is replaced with a symlink.James Pickens, Jul 28, 2009
  3. 2/2 Demonstrate merge failure when a directory is replaced with a symlink.James Pickens, Jul 28, 2009
  4. Michael J GruberJul 29, 2009
  5. Pickens, James EJul 29, 2009
  6. Michael J GruberJul 29, 2009
  7. Junio C HamanoJul 29, 2009
  8. Pickens, James EJul 29, 2009
  9. Demonstrate bugs when a directory is replaced with a symlinkPickens, James E, Jul 29, 2009
  10. Junio C HamanoJul 29, 2009
  11. Demonstrate bugs when a directory is replaced with a symlinkPickens, James E, Jul 29, 2009
  12. Linus TorvaldsJul 29, 2009
  13. Junio C HamanoJul 29, 2009
  14. Kjetil BarvikJul 29, 2009
  15. Linus TorvaldsJul 29, 2009
  16. Linus TorvaldsJul 30, 2009
  17. Junio C HamanoJul 30, 2009
  18. Junio C HamanoJul 30, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.