From: Ramkumar Ramachandra Date: Mon, 18 Mar 2013 13:16:15 GMT Subject: [PATCH 4/4] remote.c: introduce branch..pushremote Message-ID: <1363612575-7340-5-git-send-email-artagnon@gmail.com> In-Reply-To: <1363612575-7340-1-git-send-email-artagnon@gmail.com> This new configuration variable overrides `remote.pushdefault` and `branch..remote` for pushes. In a typical triangular-workflow setup, you would want to set `remote.pushdefault` to specify the remote to push to for all branches, and use this option to override it for a specific branch. Signed-off-by: Ramkumar Ramachandra --- Documentation/config.txt | 18 ++++++++++++++---- remote.c | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 8ddd0fd..d0e36e9 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -726,9 +726,18 @@ branch..remote:: When on branch , it tells 'git fetch' and 'git push' which remote to fetch from/push to. The remote to push to may be overriden with `remote.pushdefault` (for all branches). - If no remote is configured, or if you are not on any branch, - it defaults to `origin` for fetching and `remote.pushdefault` - for pushing. + The remote to push to, for the current branch, may be further + overriden by `branch..pushremote`. If no remote is + configured, or if you are not on any branch, it defaults to + `origin` for fetching and `remote.pushdefault` for pushing. + +branch..pushremote:: + When on branch , it overrides `branch..remote` + when pushing. It also overrides `remote.pushdefault` when + pushing from branch . In a typical triangular-workflow + setup, you would want to set `remote.pushdefault` to specify + the remote to push to for all branches, and use this option to + override it for a specific branch. branch..merge:: Defines, together with branch..remote, the upstream branch @@ -1899,7 +1908,8 @@ receive.updateserverinfo:: remote.pushdefault:: The remote to push to by default. Overrides - `branch..remote` for all branches. + `branch..remote` for all branches, and is overriden by + `branch..pushremote` for specific branches. remote..url:: The URL of a remote repository. See linkgit:git-fetch[1] or diff --git a/remote.c b/remote.c index 987edc4..a4d3d22 100644 --- a/remote.c +++ b/remote.c @@ -366,6 +366,9 @@ static int handle_config(const char *key, const char *value, void *cb) default_remote_name = branch->remote_name; explicit_default_remote_name = 1; } + } else if (!strcmp(subkey, ".pushremote")) { + if (branch == current_branch) + git_config_string(&pushremote_name, key, value); } else if (!strcmp(subkey, ".merge")) { if (!value) return config_error_nonbool(key); -- 1.8.2