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

Re: git-checkout-index, flag ordering and --prefix kludgy handling

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


On Mon, 17 Oct 2005, Junio C Hamano wrote:
One reason I have not done nor said much about this was because
I've been thinking about making the branch/refname more explicit
on our command line.
Yes, I know it's ambigious at times, but it really is very convenient. 
Usually we allow a "--" to say where a filename starts when it _is_ 
ambiguous.

However, you're right, we fail that at times. In particular, git-rev-parse 
fails it.

Something like this?

		Linus
---
diff --git a/rev-parse.c b/rev-parse.c
index 41b9dae..85230df 100644
--- a/rev-parse.c
+++ b/rev-parse.c
@@ -151,6 +151,12 @@ static void show_datestring(const char *
 	show(buffer);
 }
 
+static void show_file(const char *arg)
+{
+	if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV))
+		show(arg);
+}
+
 int main(int argc, char **argv)
 {
 	int i, as_is = 0, verify = 0;
@@ -162,7 +168,7 @@ int main(int argc, char **argv)
 		char *dotdot;
 	
 		if (as_is) {
-			show(arg);
+			show_file(arg);
 			continue;
 		}
 		if (*arg == '-') {
@@ -282,9 +288,7 @@ int main(int argc, char **argv)
 		}
 		if (verify)
 			die("Needed a single revision");
-		if ((filter & (DO_NONFLAGS|DO_NOREV)) ==
-		    (DO_NONFLAGS|DO_NOREV))
-			show(arg);
+		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