[prev in list] [next in list] [prev in thread] [next in thread]
List: git
Subject: Re: [PATCH] Extend "checkout --track" DWIM to support more cases
From: Johannes Schindelin <Johannes.Schindelin () gmx ! de>
Date: 2008-08-20 20:16:19
Message-ID: alpine.DEB.1.00.0808202213340.24820 () pacific ! mpi-cbg ! de ! mpi-cbg ! de
[Download RAW message or body]
Hi,
On Wed, 20 Aug 2008, Alex Riesen wrote:
> Johannes Schindelin, Wed, Aug 20, 2008 21:52:23 +0200:
> > On Wed, 20 Aug 2008, Alex Riesen wrote:
> > > - slash = strchr(argv[0], '/');
> > > - if (slash && !prefixcmp(argv[0], "refs/"))
> > > - slash = strchr(slash + 1, '/');
> > > - if (slash && !prefixcmp(argv[0], "remotes/"))
> > > - slash = strchr(slash + 1, '/');
> >
> > Why is this not enough? It strips refs/ if there is one, and remotes/ if
> > there is one (possibly after stripping refs/). No?
> >
>
> 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], '/');
+ }
if (slash && !prefixcmp(argv[0], "remotes/"))
slash = strchr(slash + 1, '/');
if (!slash || !slash[1])
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic