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

[PATCH 0/6] Default remote

From
marcnarc@xiplink.com <marcnarc@xiplink.com>
Date
Jul 5, 2012, 22:11 UTC
Message-ID
<1341526277-17055-1-git-send-email-marcnarc@xiplink.com>

This series is a follow-up to an earlier patch and discussion[1] that suggested adding a remote.default setting.

The first patch simply renames a couple of variables in remote.c so that the second patch is easier to understand.

The second patch teaches remote.c to look for remote.default in the config:
 - When deciding which remote to use, the code first tries the currently
   checked-out branch's remote.  If there isn't one it tries remote.default,
   and if that also fails it falls back to "origin".
 - The patch also adds a couple of helper functions for other code to use:
   remote_get_default_name() and remote_count().  remote_get_default_name()
   returns the value of remote.default, or "origin" if it's not configured
   (this preserves existing behavior).  remote_count() is used in patch
   four by "git remote add".
The third patch teaches "git clone" to set remote.default.

The fourth patch teaches "git remote" about remote.default. In addition to modifying the existing "add" "rm" and "rename" commands, it also adds a new "git remote default" command to get/set remote.default. The advantage of this over just using "git config" directly is twofold:

 - "git remote default foo" checks that foo is a configured remote.
 - "git remote default" (with no parameter) returns "origin" if 
   remote.default isn't configured.

Note that this patch changes the way push.default=matching works when the currently checked-out branch has no remote. Before "git push" would error out with "No configured push destination" but now it succeeds with "Everything up-to-date". I personally think this is a good thing.

The fifth patch just adds a test that plain "git fetch" respects remote.default when on remoteless branch. I suppose it could be squashed into patch four, but it's really more of a side-effect of that work and not strictly required by it. So I felt patch four would be more understandable without it.

The sixth patch changes git-parse-remote.sh:get_default_remote() to use "git remote default" instead of implementing its own default-finding logic. Because "git remote default" returns "origin" when no remote.default is configured, this change preserves the old behavior in existing repos. The test accompanying this patch essentially tests the same condition that inspired the original discussion[1]. (git-submodule is pretty much the only thing that uses get_default_remote().)

This series still needs documentation updates, which I'll do if/when we agree on the code changes.

		M.
[1] http://article.gmane.org/gmane.comp.version-control.git/200145
Marc Branchaud (6):
      Rename remote.c's default_remote_name static variables.
      Teach remote.c about the remote.default configuration setting.
      Teach clone to set remote.default.
      Teach "git remote" about remote.default.
      Test that plain "git fetch" uses remote.default when on a detached HEAD.
      Teach get_default_remote to respect remote.default.
 builtin/clone.c            |  2 ++
 builtin/remote.c           | 29 +++++++++++++++++++++
 git-parse-remote.sh        |  5 +---
 remote.c                   | 35 ++++++++++++++++++++-----
 remote.h                   |  2 ++
 t/t5505-remote.sh          | 64 ++++++++++++++++++++++++++++++++++++++++++++++
 t/t5510-fetch.sh           | 17 ++++++++++++
 t/t5512-ls-remote.sh       |  8 +++++-
 t/t5528-push-default.sh    |  4 +--
 t/t5601-clone.sh           | 10 ++++++++
 t/t5702-clone-options.sh   |  7 +++--
 t/t7400-submodule-basic.sh | 21 +++++++++++++++
 12 files changed, 188 insertions(+), 16 deletions(-)
Next: marcnarc@xiplink.com
Message 1 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.