git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Paul Mackerras <paulus@samba.org>
Cc: git@vger.kernel.org
Subject: Re: lstat() call in rev-parse.c
Date: Sun, 23 Apr 2006 09:19:30 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0604230906370.3701@g5.osdl.org> (raw)
In-Reply-To: <17483.27938.890830.375324@cargo.ozlabs.ibm.com>



On Sun, 23 Apr 2006, Paul Mackerras wrote:
>
> Why does git-rev-parse do an lstat on some of its arguments, at line
> 345 of rev-parse.c, and die if the lstat fails?  It doesn't seem to do
> anything with the result.
> 
> The effect is that if you do "gitk a b", it works as long as a and b
> exist (as files or directories), but fails if they don't, and some
> users have found this confusing.

Because it's even _more_ common to do

	gitk v2.6.16

(in the git directory) and be very confused when that returns an empty 
history. 

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 ;)

And yes, this actually happened to me. I was demonstrating git before we 
did that fix, and I used the wrong tag-name, and gitk would think for a 
minute and them show "No commits selected" with no error, because 
"v2.6.16" didn't exist at that time, and it used the "tag-name" as a 
filename, and that filename didn't actually exist, so the number of 
commits that changed it was exactly zero.

So now, if you do "gitk v2.6.16" in the git directory, it will return a 
nice and understandable 

	Error reading commits: fatal: 'v2.6.16': No such file or directory

which is _exactly_ what you want. The only problem is that gitk will 
actually open the big window too, and the error window is small and can be 
non-obvious if the window manager hides it in some corner. So I actually 
think you should try to make the error window come up smack dab in front 
of the main gitk window and make the error clearer.

So the rules are simple:
 - the filenames are _always_ separated by "--"
 - we have a short-hand, which allows the "--" to be dropped iff it is 
   unambiguous

Where "unambiguous" means that
 - the revision name cannot possible be interpreted as a filename (we 
   don't check this part yet, but I think we should)
 - all filenames are obviously not revision names, since they not 
   only aren't valid revisions, they actually exist as files.

Otherwise, misspellings, typos, and thinkos result in total confusion.

		Linus

  reply	other threads:[~2006-04-23 16:19 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 [this message]
2006-04-24 23:23   ` Paul Mackerras
2006-04-26 15:28   ` Matthias Lederhofer
2006-04-26 15:43     ` Linus Torvalds
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.0604230906370.3701@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=git@vger.kernel.org \
    --cc=paulus@samba.org \
    /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).