From: Linus Torvalds <torvalds@osdl.org>
To: Matthias Lederhofer <matled@gmx.net>
Cc: git@vger.kernel.org
Subject: Re: lstat() call in rev-parse.c
Date: Wed, 26 Apr 2006 08:43:47 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0604260832240.3701@g5.osdl.org> (raw)
In-Reply-To: <E1FYlwn-0005mf-CL@moooo.ath.cx>
On Wed, 26 Apr 2006, Matthias Lederhofer wrote:
> > So the rule is: if you don't give that "--", then we have to be able
> > to confirm that the filenames are really files. Not a misspelled
> > revision name, or a revision name that was correctly spelled, but for
> > the wrong project, because you were in the wrong subdirectory ;)
>
> Shouldn't git rev-parse try to stat the file (additionally?) in the
> current directory instead of the top git directory? git (diff|log|..)
> seem to fail everytime in a subdirectory without --.
Good point. However, the reason for that is that it actually _does_ stat
the file in the current directory, but it has done the
revs->prefix = setup_git_directory();
in the init path (and it does need to do that, since that's what figures
out where the .git directory is, so that we can parse the revisions
correctly).
And that "setup_git_directory()" will chdir() to the root of the project.
So the "lstat()" should probably take "revs->prefix" into account, the
way get_pathspec() does. Ie we should probably use
char *name = argv[i];
if (rev->prefix)
name = prefix_filename(rev->prefix, strlen(rev->prefix), name);
if (lstat(name, ..) < 0)
die(...)
instead of just a plain lstat().
Probably worth doing as a small helper funtion of its own (and get rid of
the current "die_badfile()" - and do all of that inside the helper
function).
Somebody?
Linus
next prev parent reply other threads:[~2006-04-26 15:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-23 12:03 lstat() call in rev-parse.c Paul Mackerras
2006-04-23 16:19 ` Linus Torvalds
2006-04-24 23:23 ` Paul Mackerras
2006-04-26 15:28 ` Matthias Lederhofer
2006-04-26 15:43 ` Linus Torvalds [this message]
2006-04-26 17:15 ` [PATCH] Fix filename verification when in a subdirectory Linus Torvalds
2006-04-26 18:05 ` Timo Hirvonen
2006-04-26 18:14 ` Linus Torvalds
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=Pine.LNX.4.64.0604260832240.3701@g5.osdl.org \
--to=torvalds@osdl.org \
--cc=git@vger.kernel.org \
--cc=matled@gmx.net \
/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).