Re: Fix git-rev-parse over-eager errors
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Feb 5, 2006, 22:03 UTC
- Message-ID
- <Pine.LNX.4.64.0602051355430.3854@g5.osdl.org>
- In-Reply-To
- <7vpsm1h8ft.fsf@assigned-by-dhcp.cox.net>
On Sun, 5 Feb 2006, Junio C Hamano wrote:
Show 8 quoted lines
> > Linus Torvalds <torvalds@osdl.org> writes: > > > > Using "--verify" together with "--no-flags" makes perfect sense, but > > git-rev-parse would complain about it when it saw a flag, even though it > > would never actually use/output that flag. > > Ah, makes sense.
Btw, I think the exact same holds true for the "show_file()" case.
You had added a special-case for a similar problem (the "lstat()" check) to disable the check when the path wasn't actually printed out. Strictly speaking, I think that should be handled the same way wrt "verify" too.
Ie something like this.
Comments?
Linus
---
diff --git a/rev-parse.c b/rev-parse.c index d2f0864..124d3ee 100644 --- a/rev-parse.c +++ b/rev-parse.c @@ -143,11 +143,14 @@ static void show_datestring(const char * show(buffer); } -static void show_file(const char *arg) +static int show_file(const char *arg) { show_default(); - if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV)) + if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV)) { show(arg); + return 1; + } + return 0; } int main(int argc, char **argv) @@ -308,14 +311,13 @@ int main(int argc, char **argv) show_rev(REVERSED, sha1, arg+1); continue; } + as_is = 1; + if (!show_file(arg)) + continue; if (verify) die("Needed a single revision"); - if ((filter & DO_REVS) && - (filter & DO_NONFLAGS) && /* !def && */ - lstat(arg, &st) < 0) + if (lstat(arg, &st) < 0) die("'%s': %s", arg, strerror(errno)); - as_is = 1; - show_file(arg); } show_default(); if (verify && revs_count != 1)