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

Re: Cloning a custom refspec does not work as expected

From
Stefan Beller <sbeller@google.com>
Date
May 3, 2017, 18:27 UTC
Message-ID
<CAGZ79kb=x38ELzZK3jxh1v6ivWD=D9_=-2nGCwR_m+zN0S0oSQ@mail.gmail.com>
In-Reply-To
<CAHGBnuMUrNFv30d+pjheiCAikM89XshQTFuDXBzu+EcxNY_94w@mail.gmail.com>

On Wed, May 3, 2017 at 5:16 AM, Sebastian Schuberth <sschuberth@gmail.com> wrote:

Show 26 quoted lines
> Hi,
>
> I'm trying to clone a custom ref, avoiding the need to init && fetch
> manually. From reading [1] which says:
>
> "Set a configuration variable in the newly-created repository; this
> takes effect immediately after the repository is initialized, but
> before the remote history is fetched or any files checked out. [...]
> This makes it safe, for example, to add additional fetch refspecs to
> the origin remote."
>
> I'd assume that this would work:
>
> $ git clone -c remote.origin.fetch=+refs/changes/*:refs/remotes/origin/changes/*
> https://gerrit.googlesource.com/git-repo
>
> In fact, this *does* add the custom refs correct to .git/config, but
> they are not fetched during the clone. I can manually fix that by
> doing
>
> $ cd git-repo
> $ git fetch
>
> afterwards, but the whole point is to avoid exactly that separate step.
>
> Is this a code bug or documentation bug?

I would blame the code to be buggy, as it first writes out the config and then doesn't read the config, but blindly performs some magic to come up with the refspec to fetch and performs that fetch.

Thanks, Stefan

Show 7 quoted lines
>
> I'm using git version 2.12.2.windows.2.
>
> [1] https://git-scm.com/docs/git-clone#git-clone---configltkeygtltvaluegt
>
> --
> Sebastian Schuberth
Previous: Sebastian SchuberthNext: Jeff King
Message 2 of 3 in “Cloning a custom refspec does not work as expected”
  1. Sebastian SchuberthMay 3, 2017
  2. Stefan BellerMay 3, 2017
  3. Jeff KingMay 3, 2017

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.