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

Re: [PATCH v2 3/3] clone: use remote branch if it matches default HEAD

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 8, 2022, 16:28 UTC
Message-ID
<xmqq8rp3wovj.fsf@gitster.g>
In-Reply-To
<YsdzZxS48u8sk9QD@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> +		/*
> +		 * We may have selected a local default branch name "foo",
> +		 * and even though the remote's HEAD does not point there,
> +		 * it may still have a "foo" branch. If so, set it up so
> +		 * that we can follow the usual checkout code later.
Very sensible.
Show 10 quoted lines
> +		 *
> +		 * Note that for an empty repo we'll already have set
> +		 * option_no_checkout above, which would work against us here.
> +		 * But for an empty repo, find_remote_branch() can never find
> +		 * a match.
> +		 */
> +		our_head_points_at = find_remote_branch(mapped_refs, branch);
> +
> +		if (!option_bare && !our_head_points_at)
>  			install_branch_config(0, branch, remote_name, ref);

I may be completely confused, but shouldn't the condition read "if we are not bare, and we did find the 'branch' in their refs", i.e. without "!" in front of our_head_points_at?

Previous: Jeff KingNext: Jeff King
Message 15 of 21 in “cloning unborn HEAD when other branches are present”
  1. 0/3 cloning unborn HEAD when other branches are presentJeff King, Jul 6, 2022
  2. 1/3 clone: drop extra newline from warning messageJeff King, Jul 6, 2022
  3. 2/3 clone: factor out unborn head setup into its own functionJeff King, Jul 6, 2022
  4. 3/3 clone: propagate empty remote HEAD even with other branchesJeff King, Jul 6, 2022
  5. Junio C HamanoJul 6, 2022
  6. Junio C HamanoJul 6, 2022
  7. Jeff KingJul 7, 2022
  8. Junio C HamanoJul 7, 2022
  9. 0/3 cloning unborn HEAD when other branches are presentJeff King, Jul 7, 2022
  10. 1/3 clone: drop extra newline from warning messageJeff King, Jul 7, 2022
  11. 2/3 clone: propagate empty remote HEAD even with other branchesJeff King, Jul 7, 2022
  12. Junio C HamanoJul 8, 2022
  13. Jeff KingJul 8, 2022
  14. 3/3 clone: use remote branch if it matches default HEADJeff King, Jul 7, 2022
  15. Junio C HamanoJul 8, 2022
  16. Jeff KingJul 8, 2022
  17. Junio C HamanoJul 8, 2022
  18. 4/3 clone: move unborn head creation to update_head()Jeff King, Jul 11, 2022
  19. Junio C HamanoJul 11, 2022
  20. Jeff KingJul 7, 2022
  21. Jonathan TanJul 6, 2022

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.