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

Re: [PATCH] Extend "checkout --track" DWIM to support more cases

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:45:11

Possibly related (same subject, not in this thread)

Alex Riesen [off-list ref] writes:
Johannes Schindelin, Wed, Aug 20, 2008 22:16:19 +0200:
quoted
quoted
No. It strips refs/ OR remotes/ (because of prefixcmp with argv[0]).
And I still wanted refs/<namespace>/something...
Yes, you are correct.  However, to fix my thinko, I deem this preferable:

-- snipsnap --

 builtin-checkout.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/builtin-checkout.c b/builtin-checkout.c
index e95eab9..2a076cf 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -448,8 +448,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 		if (!argc || !strcmp(argv[0], "--"))
 			die ("--track needs a branch name");
 		slash = strchr(argv[0], '/');
-		if (slash && !prefixcmp(argv[0], "refs/"))
-			slash = strchr(slash + 1, '/');
+		if (slash && !prefixcmp(argv[0], "refs/")) {
+			argv[0] = slash + 1;
+			slash = strchr(argv[0], '/');
+		}
Yes, I agree (and its shorter). The git-checkout manpage can be
improved, too (no DWIM is obvious, except may be for the implementor).
I think that makes sense.  Care to send an appliable patch with
documentation updates, please?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help