From: Marc Branchaud <marcnarc@xiplink.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jens.Lehmann@web.de, peff@peff.net,
phil.hord@gmail.com
Subject: Re: [PATCH 3/6] Teach "git remote" about remote.default.
Date: Fri, 13 Jul 2012 15:54:00 -0400 [thread overview]
Message-ID: <50007CD8.3040802@xiplink.com> (raw)
In-Reply-To: <7vd342dku3.fsf@alter.siamese.dyndns.org>
On 12-07-11 05:55 PM, Junio C Hamano wrote:
> Marc Branchaud <marcnarc@xiplink.com> writes:
>
>> What about a warning displayed if "remote.default" is not set? Something like:
>>
>> This repository does not have an explicitly configured default
>> remote. Selecting "origin" as the default remote repository.
>> To suppress this warning, or if you wish to have a different
>> default remote repository, run "git remote default <name>".
>> In git X.Y, the default remote will be automatically configured
>> as the first remote added to the repository.
>
> When do you plan to issue the above message? Any time we default to
> 'origin' without remote.default?
>
> I do not see a value to it---if the user has been happily using
> 'origin' as the default remote, there is no reason to give such a
> noise. We will keep defaulting to 'origin' even in the version of
> Git with this series in it.
>
> A warning is necessary if we plan to _later_ add the "first remote
> created either by 'git clone' or 'git remote add' is automatically
> set as the value for remote.default configuration" feature, and the
> place to do so is "git clone" and "git remote add" that creates the
> first remote for the repository. If the name of the remote created
> by them is 'origin', then there is no need for warning, but if the
> user called that first remote with a name that is _not_ 'origin',
> later versions of Git will change the behaviour.
>
> I can see a transition plan that goes like this:
I like your plan -- thanks for working it out in such detail!
I'll re-roll the series to work like your plan's Step 0, and I'll post a
separate RFC patch on top of it that initiates the transition, so folks can
discuss it specifically.
> Step 0. With this series but without the "first one becomes default"
>
> $ git init
> $ git remote add upstream git://over.there.xz/git.git/
> hint: You may want to run "git remote default upstream" now so that
> hint: a lazy 'git push' and 'git fetch' defaults to this 'upstream'
> hint: repository, instead of 'origin' (which you do not yet have).
>
> $ git config --global advice.settingDefaultRemote false
> $ git remote rm upstream
> $ git remote add upstream git://over.there.xz/git.git/
> ... nothing, as the user declined the advice ...
>
> Step 1. "First one becomes default" as an opt-in feature
>
> $ git config --global --unset advice.settingDefaultRemote
> $ git init
> $ git remote add upstream git://over.there.xz/git.git/
> hint: You may want to run "git remote default upstream" now so that
> hint: a lazy 'git push' and 'git fetch' defaults to this 'upstream'
> hint: repository, instead of 'origin' (which you do not yet have).
> hint: "git config --global remote.firstRemoteBecomesDefault true" can be
> hint: used to make the first remote added to the repository the default
> hint: remote automatically.
> $ git remote default
> origin
>
> $ git config --global remote.firstRemoteBecomesDefault true
> $ git remote rm upstream
> $ git remote add upstream git://over.there.xz/git.git/
> ... nothing; user already knows about remote.firstRemoteBecomesDefault
> $ git remote default
> upstream
>
> Step 2. Start warning the default change for "First one becomes default"
>
> $ git config --global --unset advice.settingDefaultRemote
> $ git config --global --unset remote.firstRemoteBecomesDefault
> $ git init
> $ git remote add upstream git://over.there.xz/git.git/
> hint: You may want to run "git remote default upstream" now so that
> hint: a lazy 'git push' and 'git fetch' defaults to this 'upstream'
> hint: repository, instead of 'origin' (which you do not yet have).
> hint: "git config --global remote.firstRemoteBecomesDefault true" can be
> hint: used to make the first remote added to the repository the default
> hint: remote automatically.
> hint:
> hint: In future versions of Git, this will happen automatically.
> hint: If you do not want the first remote to become default, run
> hint: "git config --global remote.firstRemoteBecomesDefault false" now.
>
> Step 3. "First one becomes default" is now default
>
> $ git config --global --unset advice.settingDefaultRemote
> $ git config --global --unset remote.firstRemoteBecomesDefault
> $ git init
> $ git remote add upstream git://over.there.xz/git.git/
> warning: Made 'upstream' the default remote for this repository.
> $ git remote default
> upstream
>
> $ git remote rm upstream
> $ git config --global remote.firstRemoteBecomesDefault true
> $ git init
> $ git remote add upstream git://over.there.xz/git.git/
> ... nothing; the user explicitly told us what to do
> $ git remote default
> upstream
>
> $ git remote rm upstream
> $ git config --global remote.firstRemoteBecomesDefault false
> $ git init
> $ git remote add upstream git://over.there.xz/git.git/
> ... nothing; the user explicitly told us what to do
> $ git remote default
> origin
>
>> Since the "cmd_" prefix is already used for the main commands, perhaps
>> another prefix for subcommands? Maybe "sub_"? Some of the shell-based
>> commands use the main command itself as a prefix (e.g. bisect_start()).
>> Doing that here would mean "remote_default()" etc. Any preference?
>
> No strong preference for file-scope-statics.
>
>>>> +{
>>>> + if (argc < 2)
>>>> + printf_ln("%s", remote_get_default_name());
>>>
>>> Good. If somebody anal cares about the vanilla hardcoded default
>>> 'origin' and 'remote.default' having 'origin' as a configured value,
>>> he should be using "git config" to ask the difference. Users of
>>> "remote default" interface should not have to care.
>>>
>>>> + else {
>>>> + const char *name = argv[1];
>>>> + if (remote_is_configured(name)) {
>>>> + git_config_set("remote.default", name);
>>>> + printf_ln(_("Default remote set to '%s'."), name);
>>>> + } else
>>>> + return error(_("No remote named '%s'."), name);
>>>> + }
>>>
>>> I am not sure if this is a good idea. Shouldn't "git remote default
>>> frotz" followed by "git remote add frotz" work?
>>
>> To me it feels wrong to allow the user to set the default remote to something
>> that doesn't actually exist. It's like trying to add a non-existent file.
>
> Every few weeks, I do this:
>
> ln -f -s Documentation/RelNotes/$new_version.txt RelNotes
> edit Documentation/RelNotes/$new_version.txt
>
>> And what if the user forgets the second step?
>
> That is why we warn on an unusual order. A lazy "git push" will
> fail and that would be sufficient clue.
>
> And another reason for the warning (with "you do not yet have") is
> to prevent this:
>
> git remote add frotz git://over.there.xz/git.git
> git remote default frozt
See, to me an error in this case makes more sense. But I feel I'm splitting
hairs now, and I'm happy to go with the warning instead.
>> It seems saner for a command to fail if it knows a change it's about to make
>> will cause problems.
>
> The point is that you do *NOT* know it will cause problems. People
> who want to do things in an unusual order *know* what they are doing
> a lot better than you do. Don't get in their way.
I'll aim to post a revised series next week.
M.
next prev parent reply other threads:[~2012-07-13 19:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-11 15:33 [PATCH v2 0/6] Default remote marcnarc
2012-07-11 15:33 ` [PATCH 1/6] Rename remote.c's default_remote_name static variables marcnarc
2012-07-11 15:33 ` [PATCH 2/6] Teach remote.c about the remote.default configuration setting marcnarc
2012-07-11 18:21 ` Junio C Hamano
2012-07-11 20:41 ` Marc Branchaud
2012-07-11 22:04 ` Junio C Hamano
2012-07-13 19:37 ` Marc Branchaud
2012-07-13 20:29 ` Junio C Hamano
2012-07-11 15:33 ` [PATCH 3/6] Teach "git remote" about remote.default marcnarc
2012-07-11 18:27 ` Junio C Hamano
2012-07-11 20:41 ` Marc Branchaud
2012-07-11 21:55 ` Junio C Hamano
2012-07-13 19:54 ` Marc Branchaud [this message]
2012-07-11 15:33 ` [PATCH 4/6] Teach clone to set remote.default marcnarc
2012-07-11 15:34 ` [PATCH 5/6] Test that plain "git fetch" uses remote.default when on a detached HEAD marcnarc
2012-07-11 15:34 ` [PATCH 6/6] Teach get_default_remote to respect remote.default marcnarc
2012-07-11 18:19 ` [PATCH v2 0/6] Default remote Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50007CD8.3040802@xiplink.com \
--to=marcnarc@xiplink.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=phil.hord@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).