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

Re: [PATCH] clone: allow detached checkout when --branch takes a tag

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 5, 2012, 16:22 UTC
Message-ID
<7v7h16nmpy.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1325771380-18862-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 7 quoted lines
> This allows you to do "git clone --branch=v1.7.8 git.git" and work
> right away from there. No big deal, just one more convenient step, I
> think. --branch taking a tag may be confusing though.
>
> We can still have master in this case instead of detached HEAD, which
> may make more sense because we use --branch. I don't care much which
> way should be used.

You clone a single lineage of the history, either shallowly or fully, either starting at the tip of one single branch or a named tag.

What is the expected use scenario of a resulting repository of this new feature? As this is creating a repository, not a tarball extract, you certainly would want the user to build further history in the resulting repository, and it would need a real branch at some point, preferably before any new commit is made. Which makes me think that the only reason we would use a detached HEAD would be because we cannot decide what name to give to that single branch and make it the responsibility of the user to run "git checkout -b $whatever" as the first thing.

I think the real cause of the above is because this patch and its previous companion patch conflate the meaning of the "--branch" option with the purpose of specifying which lineage of the history to copy. The option is described to name the local branch that is checked out, instead of using the the same name the remote's primary branch. But these patches abuse the option to name something different at the same time---the endpoint of the single lineage to be copied.

These two may often be the same, and use of "clone --branch=master" in such a case would mean that you want to name the local branch of the final checkout to be "master" _and_ the endpoint of the single lineage you are copying is also their "master".

But the "tag" extension proposed with this change is different.

You are specifying an endpoint of the single lineage with the option that is different from any of the branches at the origin, and because you used the "--branch" option for that purpose, you lost the way to specify the primary thing the option wanted to express: what the name of the resulting checkout should be.

Perhaps something like "clone --branch=master --$endpoint=v1.7.8" that says "I want a clone of the repository limited to a single lineage, whose history ends at the commit pointed by the v1.7.8 tag, and name the local checkout my master branch" be more appropriate?

Also, the user is likely to want to fetch and integrate from the origin with his own history. How should "git pull" and "git fetch" work in the resulting repository? What should the remote.origin.* look like?

Previous: Jeff KingNext: Nguyen Thai Ngoc Duy
Message 5 of 68 in “clone: allow detached checkout when --branch takes a tag”
  1. clone: allow detached checkout when --branch takes a tagNguyễn Thái Ngọc Duy, Jan 5, 2012
  2. Jeff KingJan 5, 2012
  3. Nguyen Thai Ngoc DuyJan 6, 2012
  4. Jeff KingJan 6, 2012
  5. Junio C HamanoJan 5, 2012
  6. Nguyen Thai Ngoc DuyJan 6, 2012
  7. 1/6 t5601: add &&Nguyễn Thái Ngọc Duy, Jan 8, 2012
  8. 2/6 clone: write detached HEAD in bare repositoriesNguyễn Thái Ngọc Duy, Jan 8, 2012
  9. 3/6 clone: factor out checkout codeNguyễn Thái Ngọc Duy, Jan 8, 2012
  10. Junio C HamanoJan 10, 2012
  11. Nguyen Thai Ngoc DuyJan 10, 2012
  12. Junio C HamanoJan 10, 2012
  13. Nguyen Thai Ngoc DuyJan 10, 2012
  14. 4/6 clone: --branch=<branch> always means refs/heads/<branch>Nguyễn Thái Ngọc Duy, Jan 8, 2012
  15. Junio C HamanoJan 10, 2012
  16. 5/6 clone: allow --branch to take a tagNguyễn Thái Ngọc Duy, Jan 8, 2012
  17. 6/6 clone: print advice on checking out detached HEADNguyễn Thái Ngọc Duy, Jan 8, 2012
  18. Junio C HamanoJan 10, 2012
  19. Nguyen Thai Ngoc DuyJan 10, 2012
  20. Junio C HamanoJan 10, 2012
  21. Nguyen Thai Ngoc DuyJan 10, 2012
  22. 00/10 nd/clone-detachedNguyễn Thái Ngọc Duy, Jan 10, 2012
  23. 00/10 nd/clone-detachedNguyễn Thái Ngọc Duy, Jan 13, 2012
  24. Junio C HamanoJan 13, 2012
  25. Nguyen Thai Ngoc DuyJan 14, 2012
  26. Junio C HamanoJan 14, 2012
  27. Nguyen Thai Ngoc DuyJan 14, 2012
  28. Junio C HamanoJan 15, 2012
  29. 00/10 nd/clone-detached rebase onto nd/clone-single-branchNguyễn Thái Ngọc Duy, Jan 16, 2012
  30. 01/10 t5601: add missing && cascadeNguyễn Thái Ngọc Duy, Jan 16, 2012
  31. 02/10 clone: write detached HEAD in bare repositoriesNguyễn Thái Ngọc Duy, Jan 16, 2012
  32. 03/10 clone: factor out checkout codeNguyễn Thái Ngọc Duy, Jan 16, 2012
  33. 04/10 clone: factor out HEAD update codeNguyễn Thái Ngọc Duy, Jan 16, 2012
  34. 05/10 clone: factor out remote ref writingNguyễn Thái Ngọc Duy, Jan 16, 2012
  35. 06/10 clone: delay cloning until after remote HEAD checkingNguyễn Thái Ngọc Duy, Jan 16, 2012
  36. 07/10 clone: --branch=<branch> always means refs/heads/<branch>Nguyễn Thái Ngọc Duy, Jan 16, 2012
  37. 08/10 clone: refuse to clone if --branch points to bogus refNguyễn Thái Ngọc Duy, Jan 16, 2012
  38. 09/10 clone: allow --branch to take a tagNguyễn Thái Ngọc Duy, Jan 16, 2012
  39. 10/10 clone: print advice on checking out detached HEADNguyễn Thái Ngọc Duy, Jan 16, 2012
  40. 01/10 t5601: add missing && cascadeNguyễn Thái Ngọc Duy, Jan 13, 2012
  41. 02/10 clone: write detached HEAD in bare repositoriesNguyễn Thái Ngọc Duy, Jan 13, 2012
  42. 03/10 clone: factor out checkout codeNguyễn Thái Ngọc Duy, Jan 13, 2012
  43. 04/10 clone: factor out HEAD update codeNguyễn Thái Ngọc Duy, Jan 13, 2012
  44. 05/10 clone: factor out remote ref writingNguyễn Thái Ngọc Duy, Jan 13, 2012
  45. 06/10 clone: delay cloning until after remote HEAD checkingNguyễn Thái Ngọc Duy, Jan 13, 2012
  46. 07/10 clone: --branch=<branch> always means refs/heads/<branch>Nguyễn Thái Ngọc Duy, Jan 13, 2012
  47. 08/10 clone: refuse to clone if --branch points to bogus refNguyễn Thái Ngọc Duy, Jan 13, 2012
  48. 09/10 clone: allow --branch to take a tagNguyễn Thái Ngọc Duy, Jan 13, 2012
  49. 10/10 clone: print advice on checking out detached HEADNguyễn Thái Ngọc Duy, Jan 13, 2012
  50. 01/10 t5601: add missing && cascadeNguyễn Thái Ngọc Duy, Jan 10, 2012
  51. 02/10 clone: write detached HEAD in bare repositoriesNguyễn Thái Ngọc Duy, Jan 10, 2012
  52. 03/10 clone: factor out checkout codeNguyễn Thái Ngọc Duy, Jan 10, 2012
  53. 04/10 clone: factor out HEAD update codeNguyễn Thái Ngọc Duy, Jan 10, 2012
  54. 05/10 clone: factor out remote ref writingNguyễn Thái Ngọc Duy, Jan 10, 2012
  55. 06/10 clone: delay cloning until after remote HEAD checkingNguyễn Thái Ngọc Duy, Jan 10, 2012
  56. Junio C HamanoJan 11, 2012
  57. Nguyen Thai Ngoc DuyJan 12, 2012
  58. Junio C HamanoJan 24, 2012
  59. Junio C HamanoJan 24, 2012
  60. Junio C HamanoJan 24, 2012
  61. Nguyen Thai Ngoc DuyJan 24, 2012
  62. 07/10 clone: --branch=<branch> always means refs/heads/<branch>Nguyễn Thái Ngọc Duy, Jan 10, 2012
  63. Junio C HamanoJan 11, 2012
  64. Nguyen Thai Ngoc DuyJan 12, 2012
  65. 08/10 clone: refuse to clone if --branch points to bogus refNguyễn Thái Ngọc Duy, Jan 10, 2012
  66. 09/10 clone: allow --branch to take a tagNguyễn Thái Ngọc Duy, Jan 10, 2012
  67. Junio C HamanoJan 11, 2012
  68. 10/10 clone: print advice on checking out detached HEADNguyễn Thái Ngọc Duy, Jan 10, 2012

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.