git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Levedahl <mlevedahl@gmail.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Mark Levedahl <mlevedahl@gmail.com>
Subject: [PATCH] Teach remote machinery about core.origin config variable
Date: Sat, 12 Jan 2008 00:54:30 -0500	[thread overview]
Message-ID: <1200117273-3524-1-git-send-email-mlevedahl@gmail.com> (raw)
In-Reply-To: <7v63xzzszp.fsf@gitster.siamese.dyndns.org>

This introduces a new configuration variable, core.origin, that
defines the name of the default remote to be used. Traditionally, this
is "origin", and could be overridden for a given branch. This change
introduces a way to redefine the default as desired and have that honored
regardless of the currently checked out head (e.g., core.origin is
used when on a detached head or any other non-tracking branch).

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
---
 Documentation/config.txt |    6 ++++++
 git-parse-remote.sh      |    5 +++--
 remote.c                 |   11 ++++++++++-
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 1b6d6d6..a0bdf14 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -291,6 +291,12 @@ core.editor::
 	`GIT_EDITOR` environment, `core.editor`, `VISUAL` and
 	`EDITOR` environment variables and then finally `vi`.
 
+core.origin::
+	The name of the remote used by default for fetch / pull. If unset,
+	origin is assumed. This value is used whenever the current branch
+	has no corresponding branch.<name>.remote, such as when working on
+	a detached head.
+
 core.pager::
 	The command that git will use to paginate output.  Can be overridden
 	with the `GIT_PAGER` environment variable.
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 695a409..c7ac7c7 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -56,8 +56,9 @@ get_remote_url () {
 
 get_default_remote () {
 	curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
-	origin=$(git config --get "branch.$curr_branch.remote")
-	echo ${origin:-origin}
+	git config --get "branch.$curr_branch.remote" ||
+	git config --get "core.origin" ||
+	echo origin
 }
 
 get_remote_default_refs_for_push () {
diff --git a/remote.c b/remote.c
index 0e00680..302d499 100644
--- a/remote.c
+++ b/remote.c
@@ -10,6 +10,7 @@ static int allocated_branches;
 
 static struct branch *current_branch;
 static const char *default_remote_name;
+static const char *core_origin;
 
 #define BUF_SIZE (2048)
 static char buffer[BUF_SIZE];
@@ -233,6 +234,11 @@ static int handle_config(const char *key, const char *value)
 			add_merge(branch, xstrdup(value));
 		return 0;
 	}
+	if (!strcmp(key, "core.origin")) {
+		if (value)
+			core_origin = xstrdup(value);
+		return 0;
+	}
 	if (prefixcmp(key,  "remote."))
 		return 0;
 	name = key + 7;
@@ -291,7 +297,6 @@ static void read_config(void)
 	int flag;
 	if (default_remote_name) // did this already
 		return;
-	default_remote_name = xstrdup("origin");
 	current_branch = NULL;
 	head_ref = resolve_ref("HEAD", sha1, 0, &flag);
 	if (head_ref && (flag & REF_ISSYMREF) &&
@@ -300,6 +305,10 @@ static void read_config(void)
 			make_branch(head_ref + strlen("refs/heads/"), 0);
 	}
 	git_config(handle_config);
+	if (!default_remote_name) {
+		default_remote_name = core_origin ?
+		core_origin : xstrdup("origin");
+	}
 }
 
 struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)
-- 
1.5.4.rc2.98.g1f3d5

  parent reply	other threads:[~2008-01-12  5:55 UTC|newest]

Thread overview: 134+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-11  3:29 Allowing override of the default "origin" nickname Mark Levedahl
2008-01-11  3:29 ` [PATCH] Teach remote machinery about remotes.default config variable Mark Levedahl
2008-01-11  3:29   ` [PATCH] git-remote - Unset remotes.default when deleting the default remote Mark Levedahl
2008-01-11  3:29     ` [PATCH] git-clone - Set remotes.default config variable Mark Levedahl
2008-01-11  3:29       ` [PATCH] git-submodule - Possibly inherit parent's default remote on init/clone Mark Levedahl
2008-01-11  8:00   ` [PATCH] Teach remote machinery about remotes.default config variable Junio C Hamano
2008-01-11 20:52     ` Mark Levedahl
2008-01-12  2:18       ` Junio C Hamano
2008-01-12  5:52         ` Mark Levedahl
2008-01-12  6:03           ` Junio C Hamano
2008-01-12  6:16             ` Mark Levedahl
2008-01-12  6:27               ` Junio C Hamano
2008-01-12 13:24                 ` Mark Levedahl
2008-01-12 18:46                   ` Junio C Hamano
2008-01-12 19:34                     ` Mark Levedahl
2008-01-12 20:24                       ` Johannes Schindelin
2008-01-12 22:29                         ` Mark Levedahl
2008-01-13 21:22                           ` Johannes Schindelin
2008-01-14  3:23                             ` Mark Levedahl
2008-01-14  4:42                               ` Junio C Hamano
2008-01-15  4:55                                 ` Mark Levedahl
2008-01-15  6:18                                   ` Junio C Hamano
2008-01-15 23:08                                     ` Mark Levedahl
2008-01-16  0:17                                       ` Johannes Schindelin
2008-01-16  1:25                                         ` Mark Levedahl
2008-01-16  1:40                                           ` Johannes Schindelin
2008-01-12 20:26                       ` Junio C Hamano
2008-01-12 22:24                         ` Mark Levedahl
2008-01-12 22:48                           ` Junio C Hamano
2008-01-13 15:47                             ` Mark Levedahl
2008-01-13 16:27                               ` [PATCH] Teach remote machinery about core.origin " Mark Levedahl
2008-01-13 16:27                                 ` [PATCH] git-remote - Unset core.origin when deleting the default remote Mark Levedahl
2008-01-13 16:27                                   ` [PATCH] git-clone - Set remotes.origin config variable Mark Levedahl
2008-01-13 16:27                                     ` [PATCH] git-submodule - Possibly inherit parent's default remote on init/clone Mark Levedahl
2008-01-13 16:27                                       ` [PATCH] Teach git-submodule to use master's remote when updating subprojects Mark Levedahl
2008-01-14 11:05                                   ` [PATCH] git-remote - Unset core.origin when deleting the default remote Jeff King
2008-01-15  5:02                                     ` Mark Levedahl
2008-01-15 16:50                                       ` Jeff King
2008-01-13 21:27                             ` [PATCH] Teach remote machinery about remotes.default config variable Johannes Schindelin
2008-01-14  1:50                               ` Junio C Hamano
2008-01-14  6:49                                 ` safecrlf not in 1.5.4 (was Re: [PATCH] Teach remote machinery about remotes.default config variable) Steffen Prohaska
     [not found]                                   ` <31687420-EB17-4651-AD6C-07213311ABDA-wjoc1KHpMeg@public.gmane.org>
2008-01-14  7:30                                     ` safecrlf not in 1.5.4 Junio C Hamano
     [not found]                                   ` < 7vejcklv84.fsf@gitster.siamese.dyndns.org>
     [not found]                                     ` <7vejcklv84.fsf-jO8aZxhGsIagbBziECNbOZn29agUkmeCHZ5vskTnxNA@public.gmane.org>
2008-01-14  8:29                                       ` Steffen Prohaska
2008-01-14 19:41                                         ` [msysGit] " Junio C Hamano
2008-01-14  9:04                                       ` Dmitry Potapov
2008-01-14 17:35                                         ` Pierre Habouzit
2008-01-14 11:18                                 ` [PATCH] Teach remote machinery about remotes.default config variable Johannes Schindelin
2008-01-14 12:16                                   ` valgrind test scripts (was Re: [PATCH] Teach remote...) Jeff King
2008-01-18  9:41                                 ` What's not in 'master' but should be Junio C Hamano
2008-01-18 10:15                                   ` Lars Hjemli
2008-01-18 10:24                                     ` Junio C Hamano
2008-01-18 10:53                                       ` Lars Hjemli
2008-01-18 11:09                                         ` Junio C Hamano
2008-01-18 11:54                                           ` Lars Hjemli
2008-01-18 12:34                                             ` Johannes Schindelin
2008-01-18 14:19                                               ` Lars Hjemli
2008-01-18 20:59                                             ` Junio C Hamano
2008-01-18 10:40                                   ` What's not in 'master', and likely not to be until 1.5.4 Junio C Hamano
2008-01-18 11:25                                     ` Johannes Sixt
2008-01-18 11:40                                       ` Junio C Hamano
2008-01-18 13:04                                         ` Steffen Prohaska
2008-01-18 13:11                                           ` Johannes Schindelin
2008-01-18 20:36                                       ` Johannes Schindelin
2008-01-18 20:58                                         ` Johannes Schindelin
2008-01-21  4:46                                           ` Shawn O. Pearce
2008-01-21 10:37                                             ` Johannes Schindelin
2008-01-23  4:44                                               ` Shawn O. Pearce
2008-01-23 11:12                                                 ` Johannes Schindelin
2008-01-18 22:07                                         ` Johannes Sixt
2008-01-18 22:37                                           ` Johannes Schindelin
2008-01-18 11:26                                     ` Jakub Narebski
2008-01-18 21:49                                       ` Junio C Hamano
2008-01-21  5:55                                         ` Imran M Yousuf
2008-01-21  6:29                                           ` Junio C Hamano
2008-01-21  6:42                                           ` Steffen Prohaska
2008-01-21  6:41                                             ` [PATCH] submodule: Document the details of the command line syntax Steffen Prohaska
2008-01-21  6:47                                               ` Junio C Hamano
2008-01-18 12:17                                     ` What's not in 'master', and likely not to be until 1.5.4 Marco Costalba
2008-01-18 12:18                                       ` Marco Costalba
2008-01-18 12:53                                     ` Steffen Prohaska
2008-01-18 13:09                                       ` Johannes Schindelin
2008-01-18 13:23                                         ` Steffen Prohaska
2008-01-21  2:37                                     ` What's not in 'master', and likely not to be in, " Junio C Hamano
2008-01-21  5:21                                       ` Linus Torvalds
2008-01-21  6:15                                         ` Junio C Hamano
2008-01-21  7:02                                           ` Junio C Hamano
2008-01-21  7:10                                             ` Junio C Hamano
2008-01-21  7:13                                               ` Junio C Hamano
2008-01-21  7:27                                                 ` Junio C Hamano
2008-01-21  8:32                                                   ` Junio C Hamano
2008-01-21  8:44                                                     ` [PATCH 1/2] read-cache.c: introduce is_racy_timestamp() helper Junio C Hamano
2008-01-21  8:46                                                     ` [PATCH 2/2] read-cache.c: fix timestamp comparison Junio C Hamano
2008-01-21 18:47                                                       ` Linus Torvalds
2008-01-21 19:06                                                         ` Johannes Schindelin
2008-01-21 19:09                                                         ` Linus Torvalds
2008-01-21 19:24                                                           ` Linus Torvalds
2008-01-21 19:26                                                             ` Johannes Schindelin
2008-01-21 19:47                                                               ` Linus Torvalds
2008-01-21 20:38                                                             ` Junio C Hamano
2008-01-21 21:22                                                               ` Linus Torvalds
2008-01-21 22:02                                                                 ` Junio C Hamano
2008-01-22  9:47                                                                 ` Junio C Hamano
2008-01-22 17:25                                                                   ` Linus Torvalds
2008-01-22 22:00                                                                 ` Linus Torvalds
2008-01-23  3:34                                                                   ` Junio C Hamano
2008-01-23  3:53                                                                     ` Linus Torvalds
2008-01-21  8:29                                             ` What's not in 'master', and likely not to be in, until 1.5.4 Johannes Sixt
2008-01-21  5:35                                       ` Daniel Barkalow
2008-01-21  8:11                                       ` Marco Costalba
2008-01-18 18:28                                   ` What's not in 'master' but should be Johannes Schindelin
2008-01-18 18:36                                     ` Johannes Schindelin
2008-02-18 19:57                                       ` Johannes Schindelin
2008-01-19  6:14                                     ` Mike Hommey
2008-01-19 15:21                                     ` [PATCH] http-push: fix webdav lock leak Grégoire Barbier
2008-01-19 23:38                                       ` Johannes Schindelin
2008-01-12 16:50           ` [PATCH] Teach remote machinery about remotes.default config variable Johannes Schindelin
2008-01-12 17:29             ` Mark Levedahl
2008-01-12 20:22               ` Johannes Schindelin
2008-01-12  5:54         ` Mark Levedahl [this message]
2008-01-12  5:54           ` [PATCH] git-remote - Unset core.origin when deleting the default remote Mark Levedahl
2008-01-12  5:54             ` [PATCH] git-clone - Set remotes.origin config variable Mark Levedahl
2008-01-12  5:54               ` [PATCH] git-submodule - Possibly inherit parent's default remote on init/clone Mark Levedahl
2008-01-11 12:03 ` Allowing override of the default "origin" nickname Johannes Schindelin
2008-01-11 13:06   ` Mark Levedahl
2008-01-11 13:52     ` Johannes Schindelin
2008-01-11 14:53       ` Mark Levedahl
2008-01-11 15:03         ` Johannes Schindelin
2008-01-11 16:39           ` Mark Levedahl
2008-01-11 17:01             ` Björn Steinbrink
2008-01-11 17:27               ` Jakub Narebski
2008-01-11 15:25         ` Jakub Narebski
2008-01-11 16:15           ` Mark Levedahl
2008-01-11 21:12             ` Johannes Schindelin
2008-01-11 23:11 ` Daniel Barkalow

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=1200117273-3524-1-git-send-email-mlevedahl@gmail.com \
    --to=mlevedahl@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).