Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: Fix git-rev-parse over-eager errors

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:18
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)


On Sun, 5 Feb 2006, Junio C Hamano wrote:
Linus Torvalds [off-list ref] writes:
quoted
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)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help