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

Re: [PATCH v2] clone: respect configured fetch respecs during initial fetch

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 31, 2016, 18:56 UTC
Message-ID
<xmqq1t6qo4rd.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqq1t6qr5c1.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 23 quoted lines
> Is the expectation like this?
>
>     git init
>     git config ... # set default configuration and origin remote
>     git config var val # update with what "-c var=val" told us
>     git fetch
>     git checkout   # unless '--bare' is given
>
> or is it something else?
>
> Is "-c var=val" adding to the config variables set by default, or is
> it replacing them?  Does the choice depend on the nature of
> individual variables, and if so what is the criteria?
>
> Are all "-c var=val" update the configuration of the resulting
> repository?  Or are certain "var"s treated as special and placed in
> the config but not other "var"s?  If the latter, what makes these
> certain "var"s special?
>
> These design decisions need to be explained so that they will serve
> to guide people to decide what other variables to propagate and how
> when they have to add new configuration variables in the future.
> Otherwise we'd end up with an inconsistent mess.

The above did not start as rhetorical questions, but was merely me thinking aloud. However, it showed me a different approach might be more appropriate.

Taken as rhetorical questions, the sane answers to them would revolve around "we do not know the semantics of each and every configuration variable that will be given to this codepath, and by definition we will never know in advance the ones that will be introduced later". IOW, special casing -c remote.origin.fetch=spec is a bad idea.

So how about teaching "git clone" a new _option_ that is about what branches are followed?

	git clone $there --branches="master next pu"
would give
	[remote "origin"]
        	fetch = +refs/heads/master:refs/remotes/origin/master
        	fetch = +refs/heads/next:refs/remotes/origin/next
        	fetch = +refs/heads/pu:refs/remotes/origin/pu
instead of the usual
	[remote "origin"]
		fetch = +refs/heads/*:refs/remotes/origin/*

And that can be made to work orthognonal to --single-branch by a small additional rule: if the branch given by -b <name> (or their HEAD) is not part of --branches, then we add it to the set of branches to be followed (i.e. if you give only --single-branch, without --branches, the set of branches to be followed will become that single branch).

Hmm?
Previous: Junio C HamanoNext: SZEDER Gábor
Message 8 of 12 in “clone: make 'git clone -c remote.origin.fetch=<refspec>' work”
  1. clone: make 'git clone -c remote.origin.fetch=<refspec>' workSZEDER Gábor, Mar 7, 2016
  2. Junio C HamanoMar 7, 2016
  3. SZEDER GáborMar 7, 2016
  4. Jeff KingMar 7, 2016
  5. Junio C HamanoMar 7, 2016
  6. clone: respect configured fetch respecs during initial fetchSZEDER Gábor, Mar 30, 2016
  7. Junio C HamanoMar 31, 2016
  8. Junio C HamanoMar 31, 2016
  9. SZEDER GáborMar 31, 2016
  10. Junio C HamanoMar 31, 2016
  11. SZEDER GáborApr 1, 2016
  12. SZEDER GáborApr 1, 2016

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.