From: Junio C Hamano <hidden> Date: 2016-06-15 22:43:55
Jeff King [off-list ref] writes:
IOW, it's not intended for users to use absolute paths in this way.
However, the results for git-blame are obviously quite confusing. It
might be worth fixing, but I suspect there are many more such traps
waiting in other commands. I wonder if it would make sense to reject
pathspecs starting with '/' entirely, which would at least give us a
saner error message (and I can't think of a time when such a pathspec
would be useful)?
All correct, except...
Even more useful would be to convert
/path/to/repo/file to 'file' internally.
... that might help "cut & paste from file manager" people, and I think
we had comment session for such a patch recently on the list.
Sorry, but I lost track of that the current status of that patch. Did
it die?
From: Jeff King <hidden> Date: 2016-06-15 22:43:55
On Sun, Dec 02, 2007 at 06:40:36PM -0800, Junio C Hamano wrote:
quoted
Even more useful would be to convert
/path/to/repo/file to 'file' internally.
... that might help "cut & paste from file manager" people, and I think
we had comment session for such a patch recently on the list.
Sorry, but I lost track of that the current status of that patch. Did
it die?
I didn't pay attention to it originally, but I assume you mean the
recent patch from Robin Rosenberg (cc'd). Looking it over, I see one
obvious omission: there is no canonicalization of the paths. IOW, I
think it will break in the presence of symlinks (if I specify
/path/to/repo/file, /path/to is a symlink to /other/path, I think the
worktree will end up as /other/path/repo, and fail a string comparison
with /path/to/repo).
-Peff
From: Robin Rosenberg <hidden> Date: 2016-06-15 22:43:55
måndag 03 december 2007 skrev Jeff King:
On Sun, Dec 02, 2007 at 06:40:36PM -0800, Junio C Hamano wrote:
quoted
quoted
Even more useful would be to convert
/path/to/repo/file to 'file' internally.
... that might help "cut & paste from file manager" people, and I think
we had comment session for such a patch recently on the list.
Sorry, but I lost track of that the current status of that patch. Did
it die?
I didn't pay attention to it originally, but I assume you mean the
recent patch from Robin Rosenberg (cc'd). Looking it over, I see one
obvious omission: there is no canonicalization of the paths. IOW, I
think it will break in the presence of symlinks (if I specify
/path/to/repo/file, /path/to is a symlink to /other/path, I think the
worktree will end up as /other/path/repo, and fail a string comparison
with /path/to/repo).
No it didn't die, it's just not worked on too often. I notes, among, other things
that it's test cases were not correct, besides needing more tests.
Symlinks were not covered.
-- robin
From: Robin Rosenberg <hidden> Date: 2016-06-15 22:43:55
This patch makes it possible to drag files and directories from
a graphical browser and drop them onto a shell and feed them
to common git operations without editing away the path to the
root of the work tree.
Signed-off-by: Robin Rosenberg <redacted>
---
I will not surrender to the fierce competion on this subject. Here is an update
with hopefully correct test cases this time. (Linus. your code did not pass). Like Linus,
this code does not resolve symlinks, but I forgot to state that it is by design. It
solves my problem and happens to solve Anatols problem (actually the same since
passing absolute file names to blame is my most important use case).
-- robin
builtin-blame.c | 4 +-
setup.c | 53 +++++++++++++++++++++++
t/t3904-abspatharg.sh | 112 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 166 insertions(+), 3 deletions(-)
create mode 100755 t/t3904-abspatharg.sh
From: Johannes Schindelin <hidden> Date: 2016-06-15 22:43:56
Hi,
On Mon, 3 Dec 2007, Jeff King wrote:
On Mon, Dec 03, 2007 at 09:53:30PM +0100, Robin Rosenberg wrote:
quoted
code did not pass). Like Linus, this code does not resolve symlinks,
but I forgot to state that it is by design. It solves my problem and
By design meaning "I didn't feel like implemening it because I do not
personally care" or "I have some reason not to resolve symlinks"?
IMHO those symlinks would be a nice thing in some corner cases, but
penalise the common case. So I tend to believe the latter. (See also
Linus' message why he talks about his preference for the die() code path.)
Ciao,
Dscho
From: Robin Rosenberg <hidden> Date: 2016-06-15 22:43:56
tisdag 04 december 2007 skrev Johannes Schindelin:
Hi,
On Mon, 3 Dec 2007, Jeff King wrote:
quoted
On Mon, Dec 03, 2007 at 09:53:30PM +0100, Robin Rosenberg wrote:
quoted
code did not pass). Like Linus, this code does not resolve symlinks,
but I forgot to state that it is by design. It solves my problem and
By design meaning "I didn't feel like implemening it because I do not
personally care" or "I have some reason not to resolve symlinks"?
IMHO those symlinks would be a nice thing in some corner cases, but
penalise the common case. So I tend to believe the latter. (See also
Linus' message why he talks about his preference for the die() code path.)
Actually the forme.... I don't mind it being fixed if it doesn't cost too much.
-- robin
From: Johannes Schindelin <hidden> Date: 2016-06-15 22:43:56
Hi,
On Tue, 4 Dec 2007, Robin Rosenberg wrote:
tisdag 04 december 2007 skrev Johannes Schindelin:
quoted
On Mon, 3 Dec 2007, Jeff King wrote:
quoted
On Mon, Dec 03, 2007 at 09:53:30PM +0100, Robin Rosenberg wrote:
quoted
code did not pass). Like Linus, this code does not resolve
symlinks, but I forgot to state that it is by design. It solves my
problem and
By design meaning "I didn't feel like implemening it because I do
not personally care" or "I have some reason not to resolve
symlinks"?
IMHO those symlinks would be a nice thing in some corner cases, but
penalise the common case. So I tend to believe the latter. (See also
Linus' message why he talks about his preference for the die() code
path.)
Actually the forme.... I don't mind it being fixed if it doesn't cost
too much.
I do remember the hassles I went through with get_relative_cwd() until I
broke down and used chdir() two times (ugly). So the latter reason is
good enough that you do not even have to admit to the former reason ;-)
Ciao,
Dscho
I do remember the hassles I went through with get_relative_cwd() until I
broke down and used chdir() two times (ugly).
It really is a pretty heavy and complex operation in UNIX in general (and
open to various races too), which is why I'd generally suggest avoiding it
if you at all can.
The sad(?) part is, it's fairly trivial to do inside the Linux kernel (but
probably not in other operating systems - it's only because of our
superior dcache that we could do it). So a special system call would be no
problem at all. But obviously very unportable indeed.
Linus
From: Jeff King <hidden> Date: 2016-06-15 22:43:56
On Tue, Dec 04, 2007 at 07:59:43AM -0800, Linus Torvalds wrote:
quoted
I do remember the hassles I went through with get_relative_cwd() until I
broke down and used chdir() two times (ugly).
It really is a pretty heavy and complex operation in UNIX in general (and
open to various races too), which is why I'd generally suggest avoiding it
if you at all can.
It is more expensive, though we will be doing it once per user-supplied
pathspec, so I don't know that it will actually have an impact.
I am concerned that not supporting symlinks will make this feature
unusably annoying for some users. I used to have a home directory that
had a symlink in it, and I frequently ran into these sorts of path
comparison issues ($HOME was /home/peff, so typing ~/repo/file pointed
there, but /home was a symlink to /mnt/data/home, so any routines that
normalize the cwd used /mnt/data/home/repo, and the two never matched
up).
Hrm. Looks like somebody has already helpfully implemented
make_absolute_path, so it would just require calling that on each
argument. Something like this on top of Robin's patch:
It is more expensive, though we will be doing it once per user-supplied
pathspec, so I don't know that it will actually have an impact.
Well, I'm more worried about just bugs, actually.
Doing this right is actually rather hard. For example, our current
"make_absolute_path()" is simply not very good, and it's almost impossible
to *make* it very good.
Why? It relies on being able to get the current cwd, which isn't always
even possible on all systems. What about unreadable directories? What
about just so *deep* directories, that the cwd doesn't fit in the 1kB
allocated for it? Both do happen (people use executable but non-readable
directories for security sometimes). I'm also almost certain that you can
confuse it by renaming directories while that thing is running, etc etc.
IOW, that whole thing is simply a bug waiting to happen. The fact that it
apparently *always* runs whether needed or not just seems to make it worse
(ie if we already know our cwd, and the absolute path we have already has
that as a prefix, just strip it off, don't try to do anything complex, and
leave the complex and fragile cases for the odd-ball when the simple
approach doesn't work)
Linus
From: Jeff King <hidden> Date: 2016-06-15 22:43:56
On Tue, Dec 04, 2007 at 02:52:15PM -0800, Linus Torvalds wrote:
IOW, that whole thing is simply a bug waiting to happen. The fact that it
apparently *always* runs whether needed or not just seems to make it worse
(ie if we already know our cwd, and the absolute path we have already has
that as a prefix, just strip it off, don't try to do anything complex, and
leave the complex and fragile cases for the odd-ball when the simple
approach doesn't work)
Fair enough. Something like this then? It gets called only as a
last-ditch (though I think the 'return path' should simply be a die
-- what is the point of getting a pathspec that isn't in the repo?).
---