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

Re: [PATCH] clone: add remote.cloneDefault config option

From
Derrick Stolee <stolee@gmail.com>
Date
Aug 26, 2020, 19:04 UTC
Message-ID
<eeebff99-d585-5575-009e-83bfef5294e3@gmail.com>
In-Reply-To
<xmqqlfi1utwi.fsf@gitster.c.googlers.com>
On 8/26/2020 2:46 PM, Junio C Hamano wrote:
Show 18 quoted lines
> "Sean Barag via GitGitGadget" <gitgitgadget@gmail.com> writes:
>> This commit implements
>> `remote.cloneDefault` as a parallel to `remote.pushDefault`,
>> with prioritized name resolution:
> 
> I highly doubt that .cloneDefault is a good name.  After reading
> only the title of the patch e-mail, i.e. when the only available
> information on the change available to me was the name of the
> configuration variable and the fact that it pertains to the command
> "git clone", I thought it is to specify a URL, from which "git
> clone" without the URL would clone from that single repository.
> 
> And the name will cause the same misunderstanding to normal users,
> not just to reviewers of your patch, after this change hits a future
> Git release.
> 
> Taking a parallel from init.defaultBranchName, I would probably call
> it clone.defaultUpstreamName if I were writing this feature.

I was thinking "clone.defaultRemoteName" makes it clear we are naming the remote for the provided <url> in the command. Having

	clone.defaultUpstreamName = upstream
may look a bit confusing, while
	clone.defaultRemoteName = upstream
makes it a bit clearer that we will set
	remote.upstream.url = <url>
Show 29 quoted lines
>> diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh
>> index e69427f881..8aac67b385 100755
>> --- a/t/t5606-clone-options.sh
>> +++ b/t/t5606-clone-options.sh
>> @@ -19,6 +19,20 @@ test_expect_success 'clone -o' '
>>  
>>  '
>>  
>> +test_expect_success 'clone respects remote.cloneDefault' '
>> +
>> +	git -c remote.cloneDefault=bar clone parent clone-config &&
>> +	(cd clone-config && git rev-parse --verify refs/remotes/bar/master)
>> +
>> +'
>> +
>> +test_expect_success 'clone chooses correct remote name' '
>> +
>> +	git -c remote.cloneDefault=bar clone -o foo parent clone-o-and-config &&
>> +	(cd clone-o-and-config && git rev-parse --verify refs/remotes/foo/master)
>> +
>> +'
> 
> These two are "showing off my shiny new toy" tests, which are
> needed, but we also need negative tests where the shiny new toy does
> not kick in when it should not.  For example
> 
> 	git -c remote.cloneDefault="bad.../...name" clone parent
> 
> should fail, no?
This is an important suggestion.

Thanks, -Stolee

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 7 in “clone: add remote.cloneDefault config option”
  1. clone: add remote.cloneDefault config optionSean Barag via GitGitGadget, Aug 26, 2020
  2. Junio C HamanoAug 26, 2020
  3. Derrick StoleeAug 26, 2020
  4. Junio C HamanoAug 26, 2020
  5. Sean BaragAug 27, 2020
  6. Junio C HamanoAug 27, 2020
  7. Sean BaragAug 27, 2020

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.