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

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

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Sep 17, 2012, 12:06 UTC
Message-ID
<CACsJy8Bsps_-RaXdBd9ipWPvJukjK7mRN_wG2ezEL5d4JLyx+g@mail.gmail.com>
In-Reply-To
<1347783184-20045-1-git-send-email-ralf.thielow@gmail.com>
On Sun, Sep 16, 2012 at 3:13 PM, Ralf Thielow <ralf.thielow@gmail.com> wrote:
> +       if (option_mirror || !option_bare) {
> +               strbuf_reset(&value);

I think we should use a new strbuf local variable here to avoid resetting this. At least reviewers don't have to check if this statememt causes any effect later on because "value"'s value is gone.

Show 15 quoted lines
> +               if (option_single_branch) {
> +                       if (option_branch)
> +                               strbuf_addf(&value, "+%s%s:%s%s",
> +                                               src_ref_prefix, option_branch,
> +                                               branch_top.buf, option_branch);
> +                       else if (remote_head_points_at)
> +                               strbuf_addf(&value, "+%s:%s%s",
> +                                               remote_head_points_at->name, branch_top.buf,
> +                                               skip_prefix(remote_head_points_at->name, "refs/heads/"));
> +                       /*
> +                        * otherwise, the next "git fetch" will
> +                        * simply fetch from HEAD without updating
> +                        * any remote tracking branch, which is what
> +                        * we want.
> +                        */

Maybe document updates too? Though if it's obvious that --single-branch should prepare refspec so that only one branch is fetched later on, then maybe not.

> +               } else {
> +                       strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
> +               }

--mirror --single-branch combination does not look right. The "heads/" part is missing..

$ git branch
  master * wildmatch
$ LANG=C ./git clone --mirror --single-branch .git abc
Cloning into bare repository 'abc'...
done.
$ grep fetch abc/config
        fetch = +refs/heads/wildmatch:refs/wildmatch
$ rm -rf abc
$ LANG=C ./git clone --mirror --single-branch --branch=master .git abc
Cloning into bare repository 'abc'...
done.
$ grep fetch abc/config
        fetch = +refs/master:refs/master
-- 
Duy
Previous: Junio C HamanoNext: Nguyen Thai Ngoc Duy
Message 16 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.