git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Erik Werner <martinerikwerner@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, richih@debian.org, tboegi@web.de,
	pclouds@gmail.com, dak@gnu.org
Subject: Re: [PATCH v5 1/5] t0060: Add test for manipulating symlinks via absolute paths
Date: Mon, 3 Feb 2014 21:12:41 +0100	[thread overview]
Message-ID: <20140203201241.GB15607@mule> (raw)
In-Reply-To: <xmqq7g9cf2ty.fsf@gitster.dls.corp.google.com>

On Mon, Feb 03, 2014 at 10:50:17AM -0800, Junio C Hamano wrote:
> 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

  parent reply	other threads:[~2014-02-03 20:13 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-15 12:48 git-mv with absolute path derefereces symlinks Martin Erik Werner
2014-01-26 14:22 ` [PATCH 0/2] in-tree symlink handling with absolute paths Martin Erik Werner
2014-01-26 14:22   ` [PATCH 1/2] t0060: Add test for manipulating symlinks via " Martin Erik Werner
2014-01-26 14:22   ` [PATCH 2/2] setup: Don't dereference in-tree symlinks for " Martin Erik Werner
2014-01-26 17:19     ` Torsten Bögershausen
2014-01-27  0:07       ` Martin Erik Werner
2014-01-27  0:07         ` [PATCH v2 " Martin Erik Werner
2014-01-27  0:49           ` Duy Nguyen
2014-01-27 16:31           ` Junio C Hamano
2014-01-31 20:21           ` [PATCH v3 0/4] " Martin Erik Werner
2014-02-02  1:59             ` [PATCH v4 0/4] Handling of " Martin Erik Werner
2014-02-02  1:59               ` [PATCH v4 1/4] t0060: Add test for manipulating symlinks via " Martin Erik Werner
2014-02-02  1:59               ` [PATCH v4 2/4] t0060: Add test for prefix_path when path == work tree Martin Erik Werner
2014-02-02  1:59               ` [PATCH v4 3/4] setup: Add 'abspath_part_inside_repo' function Martin Erik Werner
2014-02-02  2:19                 ` Duy Nguyen
2014-02-02  2:23                   ` Duy Nguyen
2014-02-02 11:13                   ` Martin Erik Werner
2014-02-02 11:21                     ` David Kastrup
2014-02-02 11:37                       ` Torsten Bögershausen
2014-02-02 12:09                         ` Martin Erik Werner
2014-02-02 12:27                           ` Torsten Bögershausen
2014-02-02 12:15                     ` Duy Nguyen
2014-02-02  1:59               ` [PATCH v4 4/4] setup: Don't dereference in-tree symlinks for absolute paths Martin Erik Werner
2014-02-02 16:35               ` [PATCH v5 0/5] Handling of " Martin Erik Werner
2014-02-02 16:35                 ` [PATCH v5 1/5] t0060: Add test for manipulating symlinks via " Martin Erik Werner
2014-02-03 18:50                   ` Junio C Hamano
2014-02-03 19:52                     ` Junio C Hamano
2014-02-03 20:12                     ` Martin Erik Werner [this message]
2014-02-02 16:35                 ` [PATCH v5 2/5] t0060: Add test for prefix_path when path == work tree Martin Erik Werner
2014-02-02 16:35                 ` [PATCH v5 3/5] t0060: Add tests for prefix_path when path begins with " Martin Erik Werner
2014-02-02 16:35                 ` [PATCH v5 4/5] setup: Add 'abspath_part_inside_repo' function Martin Erik Werner
2014-02-03 21:00                   ` Junio C Hamano
2014-02-03 23:16                     ` Martin Erik Werner
2014-02-04 18:09                       ` Junio C Hamano
2014-02-04 18:32                         ` Martin Erik Werner
2014-02-02 16:35                 ` [PATCH v5 5/5] setup: Don't dereference in-tree symlinks for absolute paths Martin Erik Werner
2014-02-03  4:15                   ` Duy Nguyen
2014-02-03 13:17                     ` Martin Erik Werner
2014-02-04  0:05                       ` Junio C Hamano
2014-02-04 14:25                 ` [PATCH v6 0/6] Handling of " Martin Erik Werner
2014-02-04 14:25                   ` [PATCH v6 1/6] t3004: Add test for ls-files on symlinks via " Martin Erik Werner
2014-02-04 14:25                   ` [PATCH v6 2/6] t0060: Add test for prefix_path " Martin Erik Werner
2014-02-04 14:25                   ` [PATCH v6 3/6] t0060: Add test for prefix_path when path == work tree Martin Erik Werner
2014-02-04 14:25                   ` [PATCH v6 4/6] t0060: Add tests for prefix_path when path begins with " Martin Erik Werner
2014-02-04 20:00                     ` Torsten Bögershausen
2014-02-04 20:07                       ` Junio C Hamano
2014-02-04 14:25                   ` [PATCH v6 5/6] setup: Add 'abspath_part_inside_repo' function Martin Erik Werner
2014-02-04 19:18                     ` Junio C Hamano
2014-02-04 14:25                   ` [PATCH v6 6/6] setup: Don't dereference in-tree symlinks for absolute paths Martin Erik Werner
2014-01-31 20:22           ` [PATCH v3 1/4] t0060: Add test for manipulating symlinks via " Martin Erik Werner
2014-01-31 20:22           ` [PATCH v3 2/4] t0060: Add test for prefix_path when path == work tree Martin Erik Werner
2014-01-31 20:22           ` [PATCH v3 3/4] setup: Add 'abspath_part_inside_repo' function Martin Erik Werner
2014-01-31 22:37             ` Torsten Bögershausen
2014-02-01  1:31               ` Martin Erik Werner
2014-02-01  2:31             ` Duy Nguyen
2014-01-31 20:23           ` [PATCH v3 4/4] setup: Don't dereference in-tree symlinks for absolute paths Martin Erik Werner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140203201241.GB15607@mule \
    --to=martinerikwerner@gmail.com \
    --cc=dak@gnu.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=richih@debian.org \
    --cc=tboegi@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).