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

Re: [PATCH 4/6] Teach "git remote" about remote.default.

From
Phil Hord <phil.hord@gmail.com>
Date
Jul 6, 2012, 12:51 UTC
Message-ID
<CABURp0oYfzKrkKOZJrH2hrYMTPbFe_i5mMKQ3HnWQdGZa=oujw@mail.gmail.com>
In-Reply-To
<1341526277-17055-5-git-send-email-marcnarc@xiplink.com>
On Thu, Jul 5, 2012 at 6:11 PM,  <marcnarc@xiplink.com> wrote:
> From: Marc Branchaud <marcnarc@xiplink.com>
>
> The "rename" and "rm" commands now handle the case where the remote being
> changed is the default remote.

I think this is the right thing to do. But I noticed a subtle behavior change that we may wish to consider.

Today I might do this (contrived example):

git checkout somelocalbranch git push # pushes to "origin" by default git remote rename origin origin1 git add origin ssh://new-server/foo git push # pushes to "origin" by default

But after this change, the last command is different. Now it pushes to "origin1" because the rename set the remote.default to "origin1", even though it was previously not set at all. It did this because the "oldname" is compared to the "remote_get_default_name()", which returns "origin" by default. So the old setting, which did not exist, is now "renamed" to have an actual value, and the actual value is not "origin".

One can easily contrive an alternative example showing that this is a good thing. As I said, I think it is the right thing to do.

But it is different, I think.

I doubt many script writers are counting on default settings to carry the day, so they are probably more explicit about how they push. But I didn't see this mentioned in the patch.

Phil
Previous: marcnarc@xiplink.comNext: Marc Branchaud
Message 15 of 18 in “Default remote”
  1. 0/6 Default remotemarcnarc@xiplink.com, Jul 5, 2012
  2. 1/6 Rename remote.c's default_remote_name static variables.marcnarc@xiplink.com, Jul 5, 2012
  3. 2/6 Teach remote.c about the remote.default configuration setting.marcnarc@xiplink.com, Jul 5, 2012
  4. Junio C HamanoJul 5, 2012
  5. Marc BranchaudJul 6, 2012
  6. Junio C HamanoJul 6, 2012
  7. Marc BranchaudJul 6, 2012
  8. 3/6 Teach clone to set remote.default.marcnarc@xiplink.com, Jul 5, 2012
  9. Junio C HamanoJul 5, 2012
  10. Marc BranchaudJul 6, 2012
  11. Junio C HamanoJul 6, 2012
  12. Marc BranchaudJul 6, 2012
  13. Marc BranchaudJul 6, 2012
  14. 4/6 Teach "git remote" about remote.default.marcnarc@xiplink.com, Jul 5, 2012
  15. Phil HordJul 6, 2012
  16. Marc BranchaudJul 6, 2012
  17. 5/6 Test that plain "git fetch" uses remote.default when on a detached HEAD.marcnarc@xiplink.com, Jul 5, 2012
  18. 6/6 Teach get_default_remote to respect remote.default.marcnarc@xiplink.com, Jul 5, 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.