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

[PATCH 0/3] cloning unborn HEAD when other branches are present

From
Jeff King <peff@peff.net>
Date
Jul 6, 2022, 07:57 UTC
Message-ID
<YsVAfudoUA5YkQWH@coredump.intra.peff.net>

I ran across a situation today where I was being a little clever with manipulating branches, and the results were confusing. Basically I have an old bare server-side repo with a "master" branch, and realized that I wanted to start a new line of history, but save the old one for historical purposes. So I did this in the bare repo:

  cd bare.git
  git branch -m master old-history
  git symbolic-ref HEAD new-history

to move the old one and point HEAD at the new unborn branch. Note that I didn't just name it "master"; now that there are two lines of history, I gave them identifiable and distinct names.

My intent was to then clone and create the new history:
  git clone bare.git local-repo
  cd local-repo
  git commit [etc]
  git push

I assumed that just like in the empty-repo case, the clone would start on "new-history". But it doesn't! This series fixes it.

+cc Jonathan Tan. Definitely not your bug, as the behavior has been this way forever. But this is very adjacent to your empty-repo unborn head work from 4f37d45706 (clone: respect remote unborn HEAD, 2021-02-05), and I think harmonizing a related case.

  [1/3]: clone: drop extra newline from warning message
  [2/3]: clone: factor out unborn head setup into its own function
  [3/3]: clone: propagate empty remote HEAD even with other branches
 builtin/clone.c        | 49 ++++++++++++++++++++++++------------------
 t/t5702-protocol-v2.sh | 38 ++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 21 deletions(-)
-Peff
Next: Jeff King
Message 1 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.