git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 20, 2008, 20:16 UTC
Message-ID
<alpine.DEB.1.00.0808202213340.24820@pacific.mpi-cbg.de.mpi-cbg.de>
In-Reply-To
<20080820200440.GF16626@blimp.local>
Hi,
On Wed, 20 Aug 2008, Alex Riesen wrote:
Show 14 quoted lines
> 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])
Previous: Alex RiesenNext: Alex Riesen
Message 4 of 11 in “Extend "checkout --track" DWIM to support more cases”
  1. Extend "checkout --track" DWIM to support more casesAlex Riesen, Aug 20, 2008
  2. Johannes SchindelinAug 20, 2008
  3. Alex RiesenAug 20, 2008
  4. Johannes SchindelinAug 20, 2008
  5. Alex RiesenAug 20, 2008
  6. Junio C HamanoAug 20, 2008
  7. Extend "checkout --track" DWIM to support more casesAlex Riesen, Aug 21, 2008
  8. Junio C HamanoAug 22, 2008
  9. Alex RiesenAug 22, 2008
  10. Junio C HamanoAug 22, 2008
  11. Jay SoffianAug 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.