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

Re: [PATCH] do not overwrite untracked symlinks

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 22, 2011, 06:54 UTC
Message-ID
<7v62scftjl.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20110221194623.GA31181@localhost>
Clemens Buchacher <drizzd@aon.at> writes:
> I didn't write the test, but to me it looks like the test wants to
> make sure that while the symlink is removed, the tree it's pointing
> to is not removed.

Yes, I agree with that reading. I'd squash in this on top, first making sure that "do not overwrite untracked symlinks" (which is the title of this patch) won't be broken, and then the original test that wanted to make sure that checking out a/b/c/d when a/b is pointing to an unrelated part of the tree does not nuke whatever is pointed at that symbolic link.

Thanks.

My unhappiness with the undescriptive "check_leading_path()" still remains, though...

diff --git a/t/t6035-merge-dir-to-symlink.sh b/t/t6035-merge-dir-to-symlink.sh
index 1de285b..2599ae5 100755
--- a/t/t6035-merge-dir-to-symlink.sh
+++ b/t/t6035-merge-dir-to-symlink.sh
@@ -17,13 +17,21 @@ test_expect_success SYMLINKS 'create a commit where dir a/b changed to symlink'
 	git commit -m "dir to symlink"
 '
 
-test_expect_success SYMLINKS 'keep a/b-2/c/d across checkout' '
+test_expect_success SYMLINKS 'checkout does not clobber untracked symlink' '
 	git checkout HEAD^0 &&
 	git reset --hard master &&
 	git rm --cached a/b &&
 	git commit -m "untracked symlink remains" &&
-	 git checkout -f start^0 &&
-	 test -f a/b-2/c/d
+	test_must_fail git checkout start^0
+'
+
+test_expect_success SYMLINKS 'a/b-2/c/d is kept when clobbering symlink b' '
+	git checkout HEAD^0 &&
+	git reset --hard master &&
+	git rm --cached a/b &&
+	git commit -m "untracked symlink remains" &&
+	git checkout -f start^0 &&
+	test -f a/b-2/c/d
 '
 
 test_expect_success SYMLINKS 'checkout should not have deleted a/b-2/c/d' '
Previous: Clemens BuchacherNext: Clemens Buchacher
Message 11 of 14 in “untracked symlinks are less precious than untracked files?”
  1. Johannes SixtFeb 2, 2011
  2. Junio C HamanoFeb 2, 2011
  3. Johannes SixtFeb 2, 2011
  4. Demonstrate breakage: checkout overwrites untracked symlink with directoryJohannes Sixt, Feb 5, 2011
  5. Clemens BuchacherFeb 5, 2011
  6. Junio C HamanoFeb 9, 2011
  7. Clemens BuchacherFeb 10, 2011
  8. do not overwrite untracked symlinksClemens Buchacher, Feb 20, 2011
  9. Junio C HamanoFeb 21, 2011
  10. Clemens BuchacherFeb 21, 2011
  11. Junio C HamanoFeb 22, 2011
  12. Clemens BuchacherFeb 22, 2011
  13. Junio C HamanoFeb 22, 2011
  14. Johannes SixtFeb 15, 2011

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.