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

Re: [PATCH v5 1/5] t0060: Add test for manipulating symlinks via absolute paths

From
Martin Erik Werner <martinerikwerner@gmail.com>
Date
Feb 3, 2014, 20:12 UTC
Message-ID
<20140203201241.GB15607@mule>
In-Reply-To
<xmqq7g9cf2ty.fsf@gitster.dls.corp.google.com>
On Mon, Feb 03, 2014 at 10:50:17AM -0800, Junio C Hamano wrote:
Show 29 quoted lines
> Martin Erik Werner <martinerikwerner@gmail.com> writes:
> 
> > When symlinks in the working tree are manipulated using the absolute
> > path, git dereferences them, and tries to manipulate the link target
> > instead.
> 
> The above may a very good description of the root cause, but
> can we have description of a symptom that is visible by end-users
> that is caused by the bug being fixed with the series here, by
> ending the above like so:
> 
> 	... link target instead.  This causes "git foo bar" to
> 	misbehave in this and that way.
> 
> Testing the low-level underlying machinery like this patch does is
> not wrong per-se, but I suspect that this series was triggered by
> somebody noticing breakage in a end-user command "git foo $path"
> with $path being a full pathname to an in-tree symbolic link.  It
> wouldn't be like somebody who was bored and ran "test-path-utils"
> for fun noticed the root cause without realizing how the fix would
> affect the behaviour that would be visible to end-users, right?
> 
> Can we have that "git foo $path" to the testsuite as well?  That is
> the breakage we do not want to repeat in the future by regressing.
> 
> I am guessing "foo" is "add", but I wasn't closely following the
> progression of the series.
> 
> Thanks.

Indeed, it was first discovered via git-mv, (by Richard, using git-annex) and me reproducing and reporting it was the start of the thread: http://thread.gmane.org/gmane.comp.version-control.git/240467

In going further (PATCHv0):
> I've done a bit more digging into this: The issue applies to pretty
> much all commands which can be given paths to files which are present
> in the work tree, so add, cat-file, rev-list, etc.

At this stage I kind of dropped the reference to any specific top-level command since it seemed to apply to all of them in some way, and I figured it made more sense with a generic explanation that would apply to all commands. But it might definitely be worth to mention it in order for the commit messages to be less technical, and add at least one test which would actually trigger it in a user-manner. So for the explanation, something like that?:

	This causes for example 'git add /dir/repo/symlink' to attempt
	to add the target of the symlink rather than the symlink itself,
	which is usually not what the user intends to do.

Hmm, come to think of it, I even made some of those tests back before I found it could be narrowly tested via prefix_path... I guess I'll pick out the git-add one since it's the simplest, should that be added to t0060-path-utils.sh as well, or would it fit better in t3700-add.sh?:

>From 910d8c9f51c3b3f2c03dbf15ce3cf7ea94de8d27 Mon Sep 17 00:00:00 2001
From: Martin Erik Werner <martinerikwerner@gmail.com>
Date: Thu, 16 Jan 2014 00:24:43 +0100
Subject: [PATCH] Add test for manipulating symlinks via absolute paths

When symlinks in the working tree are manipulated using the absolute path, git derferences them, and tries to manipulate the link target instead.

Add three known-breakage tests using add, mv, and rev-list which checks this behaviour.

The failure of the git-add test is a regression introduced by 18e051a:
  setup: translate symlinks in filename when using absolute paths
(which did not take symlinks in the work tree into consideration).
---
 t/t0054-symlinks-via-abs-path.sh | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100755 t/t0054-symlinks-via-abs-path.sh
diff --git a/t/t0054-symlinks-via-abs-path.sh b/t/t0054-symlinks-via-abs-path.sh
new file mode 100755
index 0000000..0b3c91e
--- /dev/null
+++ b/t/t0054-symlinks-via-abs-path.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='symlinks via sbsolute paths
+
+This test checks the behavior when symlinks in the working tree are manipulated
+via absolute path arguments.
+'
+. ./test-lib.sh
+
+test_expect_failure SYMLINKS 'git add symlink with absolute path' '
+
+	ln -s target symlink &&
+	git add "$(pwd)/symlink"
+
+'
+
+rm -f symlink
+
+test_expect_failure SYMLINKS 'git mv symlink with absolute path' '
+
+	ln -s target symlink &&
+	git add symlink &&
+	git mv "$(pwd)"/symlink moved
+
+'
+
+rm -f symlink moved
+
+test_expect_failure 'git rev-list symlink with absolute path' '
+
+	ln -s target symlink &&
+	git add symlink &&
+	git commit -m show &&
+	test "$(git rev-list HEAD -- symlink)" = "$(git rev-list HEAD -- $(pwd)/symlink)"
+
+'
+
+test_done
-- 
1.8.5.2
Previous: Junio C HamanoNext: Martin Erik Werner
Message 28 of 56 in “git-mv with absolute path derefereces symlinks”
  1. Martin Erik WernerJan 15, 2014
  2. 0/2 in-tree symlink handling with absolute pathsMartin Erik Werner, Jan 26, 2014
  3. 1/2 t0060: Add test for manipulating symlinks via absolute pathsMartin Erik Werner, Jan 26, 2014
  4. 2/2 setup: Don't dereference in-tree symlinks for absolute pathsMartin Erik Werner, Jan 26, 2014
  5. Torsten BögershausenJan 26, 2014
  6. Martin Erik WernerJan 27, 2014
  7. 2/2 setup: Don't dereference in-tree symlinks for absolute pathsMartin Erik Werner, Jan 27, 2014
  8. Duy NguyenJan 27, 2014
  9. Junio C HamanoJan 27, 2014
  10. 0/4 setup: Don't dereference in-tree symlinks for absolute pathsMartin Erik Werner, Jan 31, 2014
  11. 0/4 Handling of in-tree symlinks for absolute pathsMartin Erik Werner, Feb 2, 2014
  12. 1/4 t0060: Add test for manipulating symlinks via absolute pathsMartin Erik Werner, Feb 2, 2014
  13. 2/4 t0060: Add test for prefix_path when path == work treeMartin Erik Werner, Feb 2, 2014
  14. 3/4 setup: Add 'abspath_part_inside_repo' functionMartin Erik Werner, Feb 2, 2014
  15. Duy NguyenFeb 2, 2014
  16. Duy NguyenFeb 2, 2014
  17. Martin Erik WernerFeb 2, 2014
  18. David KastrupFeb 2, 2014
  19. Torsten BögershausenFeb 2, 2014
  20. Martin Erik WernerFeb 2, 2014
  21. Torsten BögershausenFeb 2, 2014
  22. Duy NguyenFeb 2, 2014
  23. 4/4 setup: Don't dereference in-tree symlinks for absolute pathsMartin Erik Werner, Feb 2, 2014
  24. 0/5 Handling of in-tree symlinks for absolute pathsMartin Erik Werner, Feb 2, 2014
  25. 1/5 t0060: Add test for manipulating symlinks via absolute pathsMartin Erik Werner, Feb 2, 2014
  26. Junio C HamanoFeb 3, 2014
  27. Junio C HamanoFeb 3, 2014
  28. Martin Erik WernerFeb 3, 2014
  29. 2/5 t0060: Add test for prefix_path when path == work treeMartin Erik Werner, Feb 2, 2014
  30. 3/5 t0060: Add tests for prefix_path when path begins with work treeMartin Erik Werner, Feb 2, 2014
  31. 4/5 setup: Add 'abspath_part_inside_repo' functionMartin Erik Werner, Feb 2, 2014
  32. Junio C HamanoFeb 3, 2014
  33. Martin Erik WernerFeb 3, 2014
  34. Junio C HamanoFeb 4, 2014
  35. Martin Erik WernerFeb 4, 2014
  36. 5/5 setup: Don't dereference in-tree symlinks for absolute pathsMartin Erik Werner, Feb 2, 2014
  37. Duy NguyenFeb 3, 2014
  38. Martin Erik WernerFeb 3, 2014
  39. Junio C HamanoFeb 4, 2014
  40. 0/6 Handling of in-tree symlinks for absolute pathsMartin Erik Werner, Feb 4, 2014
  41. 1/6 t3004: Add test for ls-files on symlinks via absolute pathsMartin Erik Werner, Feb 4, 2014
  42. 2/6 t0060: Add test for prefix_path on symlinks via absolute pathsMartin Erik Werner, Feb 4, 2014
  43. 3/6 t0060: Add test for prefix_path when path == work treeMartin Erik Werner, Feb 4, 2014
  44. 4/6 t0060: Add tests for prefix_path when path begins with work treeMartin Erik Werner, Feb 4, 2014
  45. Torsten BögershausenFeb 4, 2014
  46. Junio C HamanoFeb 4, 2014
  47. 5/6 setup: Add 'abspath_part_inside_repo' functionMartin Erik Werner, Feb 4, 2014
  48. Junio C HamanoFeb 4, 2014
  49. 6/6 setup: Don't dereference in-tree symlinks for absolute pathsMartin Erik Werner, Feb 4, 2014
  50. 1/4 t0060: Add test for manipulating symlinks via absolute pathsMartin Erik Werner, Jan 31, 2014
  51. 2/4 t0060: Add test for prefix_path when path == work treeMartin Erik Werner, Jan 31, 2014
  52. 3/4 setup: Add 'abspath_part_inside_repo' functionMartin Erik Werner, Jan 31, 2014
  53. Torsten BögershausenJan 31, 2014
  54. Martin Erik WernerFeb 1, 2014
  55. Duy NguyenFeb 1, 2014
  56. 4/4 setup: Don't dereference in-tree symlinks for absolute pathsMartin Erik Werner, Jan 31, 2014

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.