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

Re: [PATCHv6] clone --single: limit the fetch refspec to fetched branch

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 18, 2012, 19:42 UTC
Message-ID
<7vk3vrm83a.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1347995660-9956-1-git-send-email-ralf.thielow@gmail.com>
Ralf Thielow <ralf.thielow@gmail.com> writes:
Show 32 quoted lines
> After running "git clone --single", the resulting repository has the
> usual default "+refs/heads/*:refs/remotes/origin/*" wildcard fetch
> refspec installed, which means that a subsequent "git fetch" will
> end up grabbing all the other branches.
>
> Update the fetch refspec to cover only the singly cloned ref instead
> to correct this.
>
> That means:
> If "--single" is used without "--branch" or "--mirror", the
> fetch refspec covers the branch on which remote's HEAD points to.
> If "--single" is used with "--branch", it'll cover only the branch
> specified in the "--branch" option.
> If "--single" is combined with "--mirror", then it'll cover all
> refs of the cloned repository.
> If "--single" is used with "--branch" that specifies a tag, then
> it'll cover only the ref for this tag.
>
> Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
> ---
>
> changes in v6
> - remove initial created tests (they tested in a too deep level)
> - add tests for "--mirror" option
> - add tests for the case of cloning a tag
> - update commit message
>
> I've tried to update "Documentation/git-clone.txt", but I don't
> know in which way this patch changes already described behaviour.
> The resulting refspec seems only be covered in the last part of
> the "--single-branch" section by describing "--no-single-branch",
> but this hasn't changed. Or did I miss something?

I do not think we are changing anything. The whole "--single-branch" was an half-baked afterthought hack that nobody anticipated the user to later issue "git fetch" in the resulting repository, and everybody involved in the series (the maintainer included) were just happy to see the resulting code only transferred objects needed for the branch without wasting bandwidth for objects needed for other branches, and stopped thinking beyond that X-<.

If anything, we need to _add_ the description of what happens when further fetches are done. The second and the third paragraph in the DESCRIPTION section talks only about the normal case, so at least at the end of the second paragraph we should say "But if you use --single-branch, all of this is different". And what happens when you do use --single-branch should be described in the part that describes that option, e.g.

 Documentation/git-clone.txt | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git c/Documentation/git-clone.txt w/Documentation/git-clone.txt
index c1ddd4c..f59bc49 100644
--- c/Documentation/git-clone.txt
+++ w/Documentation/git-clone.txt
@@ -29,7 +29,8 @@ currently active branch.
 After the clone, a plain `git fetch` without arguments will update
 all the remote-tracking branches, and a `git pull` without
 arguments will in addition merge the remote master branch into the
-current master branch, if any.
+current master branch, if any (this is untrue when "--single-branch"
+is given; see below).
 
 This default configuration is achieved by creating references to
 the remote branch heads under `refs/remotes/origin` and
@@ -152,9 +153,11 @@ objects from the source repository into a pack in the cloned repository.
 -b <name>::
 	Instead of pointing the newly created HEAD to the branch pointed
 	to by the cloned repository's HEAD, point to `<name>` branch
-	instead. `--branch` can also take tags and treat them like
-	detached HEAD. In a non-bare repository, this is the branch
+	instead. In a non-bare repository, this is the branch
 	that will be checked out.
++
+`--branch` can also take tags and detaches the HEAD
+at that commit in the resulting repository. 
 
 --upload-pack <upload-pack>::
 -u <upload-pack>::
@@ -193,6 +196,12 @@ objects from the source repository into a pack in the cloned repository.
 	clone with the `--depth` option, this is the default, unless
 	`--no-single-branch` is given to fetch the histories near the
 	tips of all branches.
++
+Further fetches into the resulting repository will only update the
+remote tracking branch for the branch this option was used for the
+initial cloning.  If the HEAD at the remote did not point at any
+branch when `--single-branch` clone was made, no remote tracking
+branch is created.
 
 --recursive::
 --recurse-submodules::
Previous: Ralf ThielowNext: Junio C Hamano
Message 25 of 39 in “is this behaviour expected for "git clone --single-branch"?”
  1. Ralf ThielowSep 13, 2012
  2. Junio C HamanoSep 13, 2012
  3. Ralf ThielowSep 13, 2012
  4. clone: fix refspec on "--single-branch" optionRalf Thielow, Sep 14, 2012
  5. Junio C HamanoSep 14, 2012
  6. Junio C HamanoSep 14, 2012
  7. Nguyen Thai Ngoc DuySep 14, 2012
  8. Ralf ThielowSep 14, 2012
  9. Junio C HamanoSep 14, 2012
  10. [PATCHv2] clone: fix refspec on "--single-branch" optionRalf Thielow, Sep 14, 2012
  11. Junio C HamanoSep 14, 2012
  12. [PATCHv3] clone: fix refspec on "--single-branch" optionRalf Thielow, Sep 14, 2012
  13. Junio C HamanoSep 14, 2012
  14. [PATCHv4] clone --single: limit the fetch refspec to fetched branchRalf Thielow, Sep 16, 2012
  15. Junio C HamanoSep 17, 2012
  16. Nguyen Thai Ngoc DuySep 17, 2012
  17. Nguyen Thai Ngoc DuySep 17, 2012
  18. [PATCHv5] clone --single: limit the fetch refspec to fetched branchRalf Thielow, Sep 17, 2012
  19. Junio C HamanoSep 17, 2012
  20. Ralf ThielowSep 17, 2012
  21. Junio C HamanoSep 17, 2012
  22. Ralf ThielowSep 18, 2012
  23. Junio C HamanoSep 18, 2012
  24. [PATCHv6] clone --single: limit the fetch refspec to fetched branchRalf Thielow, Sep 18, 2012
  25. Junio C HamanoSep 18, 2012
  26. Junio C HamanoSep 18, 2012
  27. [PATCHv7] clone --single: limit the fetch refspec to fetched branchRalf Thielow, Sep 19, 2012
  28. Junio C HamanoSep 19, 2012
  29. [PATCHv8] clone --single: limit the fetch refspec to fetched branchRalf Thielow, Sep 20, 2012
  30. Junio C HamanoSep 20, 2012
  31. Nguyen Thai Ngoc DuySep 19, 2012
  32. Ralf ThielowSep 19, 2012
  33. Junio C HamanoSep 17, 2012
  34. Nguyen Thai Ngoc DuySep 18, 2012
  35. Junio C HamanoSep 18, 2012
  36. Ralf ThielowSep 17, 2012
  37. Junio C HamanoSep 17, 2012
  38. Nguyen Thai Ngoc DuySep 18, 2012
  39. Junio C HamanoSep 14, 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.