summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-03-14 14:26:04 -0700
committerJunio C Hamano <gitster@pobox.com>2014-03-14 14:26:05 -0700
commitd52571d5c10efeb35ceeeb17f9b5e5f0ca1c3019 (patch)
tree50756c4e80c3e6faae46333eb60dff8784df7b2c
parent3c83b080e4dce42d0f48d28b03691ae1ac0dcde3 (diff)
parent98b406f3ad6a6989a5b11c2a2582a9f539d66263 (diff)
downloadgit-d52571d5c10efeb35ceeeb17f9b5e5f0ca1c3019.tar.gz
Merge branch 'jk/remote-pushremote-config-reading'
"git push" did not pay attention to branch.*.pushremote if it is defined earlier than remote.pushdefault; the order of these two variables in the configuration file should not matter, but it did by mistake. * jk/remote-pushremote-config-reading: remote: handle pushremote config in any order
-rw-r--r--remote.c7
-rwxr-xr-xt/t5516-fetch-push.sh13
2 files changed, 19 insertions, 1 deletions
diff --git a/remote.c b/remote.c
index e41251ee77..5f63d55056 100644
--- a/remote.c
+++ b/remote.c
@@ -49,6 +49,7 @@ static int branches_nr;
static struct branch *current_branch;
static const char *default_remote_name;
+static const char *branch_pushremote_name;
static const char *pushremote_name;
static int explicit_default_remote_name;
@@ -352,7 +353,7 @@ static int handle_config(const char *key, const char *value, void *cb)
}
} else if (!strcmp(subkey, ".pushremote")) {
if (branch == current_branch)
- if (git_config_string(&pushremote_name, key, value))
+ if (git_config_string(&branch_pushremote_name, key, value))
return -1;
} else if (!strcmp(subkey, ".merge")) {
if (!value)
@@ -492,6 +493,10 @@ static void read_config(void)
make_branch(head_ref + strlen("refs/heads/"), 0);
}
git_config(handle_config, NULL);
+ if (branch_pushremote_name) {
+ free((char *)pushremote_name);
+ pushremote_name = branch_pushremote_name;
+ }
alias_all_urls();
}
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 926e7f6b97..67e0ab3462 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -536,6 +536,19 @@ test_expect_success 'push with config branch.*.pushremote' '
check_push_result down_repo $the_commit heads/master
'
+test_expect_success 'branch.*.pushremote config order is irrelevant' '
+ mk_test one_repo heads/master &&
+ mk_test two_repo heads/master &&
+ test_config remote.one.url one_repo &&
+ test_config remote.two.url two_repo &&
+ test_config branch.master.pushremote two_repo &&
+ test_config remote.pushdefault one_repo &&
+ test_config push.default matching &&
+ git push &&
+ check_push_result one_repo $the_first_commit heads/master &&
+ check_push_result two_repo $the_commit heads/master
+'
+
test_expect_success 'push with dry-run' '
mk_test testrepo heads/master &&