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

Re: [PATCH] clone: Supply the right commit hash to post-checkout when -b is used

From
Jeff King <peff@peff.net>
Date
Oct 14, 2009, 00:06 UTC
Message-ID
<20091014000619.GA20496@coredump.intra.peff.net>
In-Reply-To
<20091013221109.GA30972@atjola.homenet>
On Wed, Oct 14, 2009 at 12:11:09AM +0200, Björn Steinbrink wrote:
Show 14 quoted lines
> When we use -b <branch>, we may checkout something else than what the
> remote's HEAD references, but we still used remote_head to supply the
> new ref value to the post-checkout hook, which is wrong.
> 
> So instead of using remote_head to find the value to be passed to the
> post-checkout hook, we have to use our_head_points_at, which is always
> correctly setup, even if -b is not used.
> 
> This also fixes a segfault when "clone -b <branch>" is used with a
> remote repo that doesn't have a valid HEAD, as in such a case
> remote_head is NULL, but we still tried to access it.
> 
> Reported-by: Devin Cofer <ranguvar@archlinux.us>
> Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
Acked-by: Jeff King <peff@peff.net>
Thanks.

When splitting remote_head versus our_head, I tried to find every use of the remote head and pick the appropriate variable, but I think I just missed this one. I gave the code another once-over and didn't see any other spots that needed fixing.

-Peff
Previous: Björn SteinbrinkNext: Junio C Hamano
Message 2 of 3 in “clone: Supply the right commit hash to post-checkout when -b is used”
  1. clone: Supply the right commit hash to post-checkout when -b is usedBjörn Steinbrink, Oct 13, 2009
  2. Jeff KingOct 14, 2009
  3. Junio C HamanoOct 14, 2009

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.