git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/6] Support triangular workflows
@ 2013-03-28 13:26 Ramkumar Ramachandra
  2013-03-28 13:26 ` [PATCH 1/6] remote.c: simplify a bit of code using git_config_string() Ramkumar Ramachandra
                   ` (7 more replies)
  0 siblings, 8 replies; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-28 13:26 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jeff King, Jonathan Nieder

Hi,

The changes in this round are:

1. Peff submitted a patch to squash into [3/6].  Since his patch
   essentially reverts mine, I've blamed him for the change.

2. Peff suggested a code movement in [5/6] to make things flow more
   naturally.

3. Jonathan suggested a better test description in [2/6].

4. Junio suggested a minor documentation update in [6/6].

My build of git has had this feature for two weeks now (since the
first iteration), and I'm very happy with it.

Jeff King (1):
  t5516 (fetch-push): drop implicit arguments from helper functions

Ramkumar Ramachandra (5):
  remote.c: simplify a bit of code using git_config_string()
  t5516 (fetch-push): update test description
  remote.c: introduce a way to have different remotes for fetch/push
  remote.c: introduce remote.pushdefault
  remote.c: introduce branch.<name>.pushremote

 Documentation/config.txt |  24 +++-
 builtin/push.c           |   2 +-
 remote.c                 |  41 ++++--
 remote.h                 |   1 +
 t/t5516-fetch-push.sh    | 316 +++++++++++++++++++++++++++--------------------
 5 files changed, 238 insertions(+), 146 deletions(-)

-- 
1.8.2.141.g3797f84

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 1/6] remote.c: simplify a bit of code using git_config_string()
  2013-03-28 13:26 [PATCH v4 0/6] Support triangular workflows Ramkumar Ramachandra
@ 2013-03-28 13:26 ` Ramkumar Ramachandra
  2013-03-28 13:26 ` [PATCH 2/6] t5516 (fetch-push): update test description Ramkumar Ramachandra
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-28 13:26 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jeff King, Jonathan Nieder

A small segment where handle_config() parses the branch.remote
configuration variable can be simplified using git_config_string().

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 remote.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/remote.c b/remote.c
index 174e48e..02e6c4c 100644
--- a/remote.c
+++ b/remote.c
@@ -357,9 +357,8 @@ static int handle_config(const char *key, const char *value, void *cb)
 			return 0;
 		branch = make_branch(name, subkey - name);
 		if (!strcmp(subkey, ".remote")) {
-			if (!value)
-				return config_error_nonbool(key);
-			branch->remote_name = xstrdup(value);
+			if (git_config_string(&branch->remote_name, key, value))
+				return -1;
 			if (branch == current_branch) {
 				default_remote_name = branch->remote_name;
 				explicit_default_remote_name = 1;
-- 
1.8.2.141.g3797f84

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 2/6] t5516 (fetch-push): update test description
  2013-03-28 13:26 [PATCH v4 0/6] Support triangular workflows Ramkumar Ramachandra
  2013-03-28 13:26 ` [PATCH 1/6] remote.c: simplify a bit of code using git_config_string() Ramkumar Ramachandra
@ 2013-03-28 13:26 ` Ramkumar Ramachandra
  2013-03-28 13:26 ` [PATCH 3/6] t5516 (fetch-push): drop implicit arguments from helper functions Ramkumar Ramachandra
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-28 13:26 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jeff King, Jonathan Nieder

The file was originally created in bcdb34f (Test wildcard push/fetch,
2007-06-08), and only contained tests that exercised wildcard
functionality at the time.  In subsequent commits, many other tests
unrelated to wildcards were added but the test description was never
updated.  Fix this.

Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 t/t5516-fetch-push.sh | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 6fd125a..38f8fc0 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1,6 +1,17 @@
 #!/bin/sh
 
-test_description='fetching and pushing, with or without wildcard'
+test_description='Basic fetch/push functionality.
+
+This test checks the following functionality:
+
+* command-line syntax
+* refspecs
+* fast-forward detection, and overriding it
+* configuration
+* hooks
+* --porcelain output format
+* hiderefs
+'
 
 . ./test-lib.sh
 
-- 
1.8.2.141.g3797f84

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 3/6] t5516 (fetch-push): drop implicit arguments from helper functions
  2013-03-28 13:26 [PATCH v4 0/6] Support triangular workflows Ramkumar Ramachandra
  2013-03-28 13:26 ` [PATCH 1/6] remote.c: simplify a bit of code using git_config_string() Ramkumar Ramachandra
  2013-03-28 13:26 ` [PATCH 2/6] t5516 (fetch-push): update test description Ramkumar Ramachandra
@ 2013-03-28 13:26 ` Ramkumar Ramachandra
  2013-03-28 13:26 ` [PATCH 4/6] remote.c: introduce a way to have different remotes for fetch/push Ramkumar Ramachandra
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-28 13:26 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jeff King, Jonathan Nieder

From: Jeff King <peff@peff.net>

Many of the tests in t5516 look like:

  mk_empty &&
  git push testrepo ... &&
  check_push_result $commit heads/master

It's reasonably easy to see what is being tested, with the
exception that "testrepo" is a magic global name (it is
implicitly used in the helpers, but we have to name it
explicitly when calling git directly). Let's make it
explicit when call the helpers, too. This is slightly more
typing, but makes the test snippets read more naturally.

It also makes it easy for future tests to use an alternate
or multiple repositories, without a proliferation of helper
functions.

[rr: fixed sloppy quoting]

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 t/t5516-fetch-push.sh | 276 ++++++++++++++++++++++++++------------------------
 1 file changed, 142 insertions(+), 134 deletions(-)

diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 38f8fc0..94e0189 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -18,10 +18,11 @@ This test checks the following functionality:
 D=`pwd`
 
 mk_empty () {
-	rm -fr testrepo &&
-	mkdir testrepo &&
+	repo_name="$1"
+	rm -fr "$repo_name" &&
+	mkdir "$repo_name" &&
 	(
-		cd testrepo &&
+		cd "$repo_name" &&
 		git init &&
 		git config receive.denyCurrentBranch warn &&
 		mv .git/hooks .git/hooks-disabled
@@ -29,16 +30,19 @@ mk_empty () {
 }
 
 mk_test () {
-	mk_empty &&
+	repo_name="$1"
+	shift
+
+	mk_empty "$repo_name" &&
 	(
 		for ref in "$@"
 		do
-			git push testrepo $the_first_commit:refs/$ref || {
+			git push "$repo_name" $the_first_commit:refs/$ref || {
 				echo "Oops, push refs/$ref failure"
 				exit 1
 			}
 		done &&
-		cd testrepo &&
+		cd "$repo_name" &&
 		for ref in "$@"
 		do
 			r=$(git show-ref -s --verify refs/$ref) &&
@@ -52,9 +56,10 @@ mk_test () {
 }
 
 mk_test_with_hooks() {
+	repo_name=$1
 	mk_test "$@" &&
 	(
-		cd testrepo &&
+		cd "$repo_name" &&
 		mkdir .git/hooks &&
 		cd .git/hooks &&
 
@@ -86,13 +91,16 @@ mk_test_with_hooks() {
 }
 
 mk_child() {
-	rm -rf "$1" &&
-	git clone testrepo "$1"
+	rm -rf "$2" &&
+	git clone "$1" "$2"
 }
 
 check_push_result () {
+	repo_name="$1"
+	shift
+
 	(
-		cd testrepo &&
+		cd "$repo_name" &&
 		it="$1" &&
 		shift
 		for ref in "$@"
@@ -124,7 +132,7 @@ test_expect_success setup '
 '
 
 test_expect_success 'fetch without wildcard' '
-	mk_empty &&
+	mk_empty testrepo &&
 	(
 		cd testrepo &&
 		git fetch .. refs/heads/master:refs/remotes/origin/master &&
@@ -137,7 +145,7 @@ test_expect_success 'fetch without wildcard' '
 '
 
 test_expect_success 'fetch with wildcard' '
-	mk_empty &&
+	mk_empty testrepo &&
 	(
 		cd testrepo &&
 		git config remote.up.url .. &&
@@ -152,7 +160,7 @@ test_expect_success 'fetch with wildcard' '
 '
 
 test_expect_success 'fetch with insteadOf' '
-	mk_empty &&
+	mk_empty testrepo &&
 	(
 		TRASH=$(pwd)/ &&
 		cd testrepo &&
@@ -169,7 +177,7 @@ test_expect_success 'fetch with insteadOf' '
 '
 
 test_expect_success 'fetch with pushInsteadOf (should not rewrite)' '
-	mk_empty &&
+	mk_empty testrepo &&
 	(
 		TRASH=$(pwd)/ &&
 		cd testrepo &&
@@ -186,7 +194,7 @@ test_expect_success 'fetch with pushInsteadOf (should not rewrite)' '
 '
 
 test_expect_success 'push without wildcard' '
-	mk_empty &&
+	mk_empty testrepo &&
 
 	git push testrepo refs/heads/master:refs/remotes/origin/master &&
 	(
@@ -199,7 +207,7 @@ test_expect_success 'push without wildcard' '
 '
 
 test_expect_success 'push with wildcard' '
-	mk_empty &&
+	mk_empty testrepo &&
 
 	git push testrepo "refs/heads/*:refs/remotes/origin/*" &&
 	(
@@ -212,7 +220,7 @@ test_expect_success 'push with wildcard' '
 '
 
 test_expect_success 'push with insteadOf' '
-	mk_empty &&
+	mk_empty testrepo &&
 	TRASH="$(pwd)/" &&
 	git config "url.$TRASH.insteadOf" trash/ &&
 	git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
@@ -226,7 +234,7 @@ test_expect_success 'push with insteadOf' '
 '
 
 test_expect_success 'push with pushInsteadOf' '
-	mk_empty &&
+	mk_empty testrepo &&
 	TRASH="$(pwd)/" &&
 	git config "url.$TRASH.pushInsteadOf" trash/ &&
 	git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
@@ -240,7 +248,7 @@ test_expect_success 'push with pushInsteadOf' '
 '
 
 test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf should not rewrite)' '
-	mk_empty &&
+	mk_empty testrepo &&
 	TRASH="$(pwd)/" &&
 	git config "url.trash2/.pushInsteadOf" trash/ &&
 	git config remote.r.url trash/wrong &&
@@ -257,242 +265,242 @@ test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf
 
 test_expect_success 'push with matching heads' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	git push testrepo &&
-	check_push_result $the_commit heads/master
+	check_push_result testrepo $the_commit heads/master
 
 '
 
 test_expect_success 'push with matching heads on the command line' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	git push testrepo : &&
-	check_push_result $the_commit heads/master
+	check_push_result testrepo $the_commit heads/master
 
 '
 
 test_expect_success 'failed (non-fast-forward) push with matching heads' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	git push testrepo : &&
 	git commit --amend -massaged &&
 	test_must_fail git push testrepo &&
-	check_push_result $the_commit heads/master &&
+	check_push_result testrepo $the_commit heads/master &&
 	git reset --hard $the_commit
 
 '
 
 test_expect_success 'push --force with matching heads' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	git push testrepo : &&
 	git commit --amend -massaged &&
 	git push --force testrepo &&
-	! check_push_result $the_commit heads/master &&
+	! check_push_result testrepo $the_commit heads/master &&
 	git reset --hard $the_commit
 
 '
 
 test_expect_success 'push with matching heads and forced update' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	git push testrepo : &&
 	git commit --amend -massaged &&
 	git push testrepo +: &&
-	! check_push_result $the_commit heads/master &&
+	! check_push_result testrepo $the_commit heads/master &&
 	git reset --hard $the_commit
 
 '
 
 test_expect_success 'push with no ambiguity (1)' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	git push testrepo master:master &&
-	check_push_result $the_commit heads/master
+	check_push_result testrepo $the_commit heads/master
 
 '
 
 test_expect_success 'push with no ambiguity (2)' '
 
-	mk_test remotes/origin/master &&
+	mk_test testrepo remotes/origin/master &&
 	git push testrepo master:origin/master &&
-	check_push_result $the_commit remotes/origin/master
+	check_push_result testrepo $the_commit remotes/origin/master
 
 '
 
 test_expect_success 'push with colon-less refspec, no ambiguity' '
 
-	mk_test heads/master heads/t/master &&
+	mk_test testrepo heads/master heads/t/master &&
 	git branch -f t/master master &&
 	git push testrepo master &&
-	check_push_result $the_commit heads/master &&
-	check_push_result $the_first_commit heads/t/master
+	check_push_result testrepo $the_commit heads/master &&
+	check_push_result testrepo $the_first_commit heads/t/master
 
 '
 
 test_expect_success 'push with weak ambiguity (1)' '
 
-	mk_test heads/master remotes/origin/master &&
+	mk_test testrepo heads/master remotes/origin/master &&
 	git push testrepo master:master &&
-	check_push_result $the_commit heads/master &&
-	check_push_result $the_first_commit remotes/origin/master
+	check_push_result testrepo $the_commit heads/master &&
+	check_push_result testrepo $the_first_commit remotes/origin/master
 
 '
 
 test_expect_success 'push with weak ambiguity (2)' '
 
-	mk_test heads/master remotes/origin/master remotes/another/master &&
+	mk_test testrepo heads/master remotes/origin/master remotes/another/master &&
 	git push testrepo master:master &&
-	check_push_result $the_commit heads/master &&
-	check_push_result $the_first_commit remotes/origin/master remotes/another/master
+	check_push_result testrepo $the_commit heads/master &&
+	check_push_result testrepo $the_first_commit remotes/origin/master remotes/another/master
 
 '
 
 test_expect_success 'push with ambiguity' '
 
-	mk_test heads/frotz tags/frotz &&
+	mk_test testrepo heads/frotz tags/frotz &&
 	if git push testrepo master:frotz
 	then
 		echo "Oops, should have failed"
 		false
 	else
-		check_push_result $the_first_commit heads/frotz tags/frotz
+		check_push_result testrepo $the_first_commit heads/frotz tags/frotz
 	fi
 
 '
 
 test_expect_success 'push with colon-less refspec (1)' '
 
-	mk_test heads/frotz tags/frotz &&
+	mk_test testrepo heads/frotz tags/frotz &&
 	git branch -f frotz master &&
 	git push testrepo frotz &&
-	check_push_result $the_commit heads/frotz &&
-	check_push_result $the_first_commit tags/frotz
+	check_push_result testrepo $the_commit heads/frotz &&
+	check_push_result testrepo $the_first_commit tags/frotz
 
 '
 
 test_expect_success 'push with colon-less refspec (2)' '
 
-	mk_test heads/frotz tags/frotz &&
+	mk_test testrepo heads/frotz tags/frotz &&
 	if git show-ref --verify -q refs/heads/frotz
 	then
 		git branch -D frotz
 	fi &&
 	git tag -f frotz &&
 	git push -f testrepo frotz &&
-	check_push_result $the_commit tags/frotz &&
-	check_push_result $the_first_commit heads/frotz
+	check_push_result testrepo $the_commit tags/frotz &&
+	check_push_result testrepo $the_first_commit heads/frotz
 
 '
 
 test_expect_success 'push with colon-less refspec (3)' '
 
-	mk_test &&
+	mk_test testrepo &&
 	if git show-ref --verify -q refs/tags/frotz
 	then
 		git tag -d frotz
 	fi &&
 	git branch -f frotz master &&
 	git push testrepo frotz &&
-	check_push_result $the_commit heads/frotz &&
+	check_push_result testrepo $the_commit heads/frotz &&
 	test 1 = $( cd testrepo && git show-ref | wc -l )
 '
 
 test_expect_success 'push with colon-less refspec (4)' '
 
-	mk_test &&
+	mk_test testrepo &&
 	if git show-ref --verify -q refs/heads/frotz
 	then
 		git branch -D frotz
 	fi &&
 	git tag -f frotz &&
 	git push testrepo frotz &&
-	check_push_result $the_commit tags/frotz &&
+	check_push_result testrepo $the_commit tags/frotz &&
 	test 1 = $( cd testrepo && git show-ref | wc -l )
 
 '
 
 test_expect_success 'push head with non-existent, incomplete dest' '
 
-	mk_test &&
+	mk_test testrepo &&
 	git push testrepo master:branch &&
-	check_push_result $the_commit heads/branch
+	check_push_result testrepo $the_commit heads/branch
 
 '
 
 test_expect_success 'push tag with non-existent, incomplete dest' '
 
-	mk_test &&
+	mk_test testrepo &&
 	git tag -f v1.0 &&
 	git push testrepo v1.0:tag &&
-	check_push_result $the_commit tags/tag
+	check_push_result testrepo $the_commit tags/tag
 
 '
 
 test_expect_success 'push sha1 with non-existent, incomplete dest' '
 
-	mk_test &&
+	mk_test testrepo &&
 	test_must_fail git push testrepo `git rev-parse master`:foo
 
 '
 
 test_expect_success 'push ref expression with non-existent, incomplete dest' '
 
-	mk_test &&
+	mk_test testrepo &&
 	test_must_fail git push testrepo master^:branch
 
 '
 
 test_expect_success 'push with HEAD' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	git checkout master &&
 	git push testrepo HEAD &&
-	check_push_result $the_commit heads/master
+	check_push_result testrepo $the_commit heads/master
 
 '
 
 test_expect_success 'push with HEAD nonexisting at remote' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	git checkout -b local master &&
 	git push testrepo HEAD &&
-	check_push_result $the_commit heads/local
+	check_push_result testrepo $the_commit heads/local
 '
 
 test_expect_success 'push with +HEAD' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	git checkout master &&
 	git branch -D local &&
 	git checkout -b local &&
 	git push testrepo master local &&
-	check_push_result $the_commit heads/master &&
-	check_push_result $the_commit heads/local &&
+	check_push_result testrepo $the_commit heads/master &&
+	check_push_result testrepo $the_commit heads/local &&
 
 	# Without force rewinding should fail
 	git reset --hard HEAD^ &&
 	test_must_fail git push testrepo HEAD &&
-	check_push_result $the_commit heads/local &&
+	check_push_result testrepo $the_commit heads/local &&
 
 	# With force rewinding should succeed
 	git push testrepo +HEAD &&
-	check_push_result $the_first_commit heads/local
+	check_push_result testrepo $the_first_commit heads/local
 
 '
 
 test_expect_success 'push HEAD with non-existent, incomplete dest' '
 
-	mk_test &&
+	mk_test testrepo &&
 	git checkout master &&
 	git push testrepo HEAD:branch &&
-	check_push_result $the_commit heads/branch
+	check_push_result testrepo $the_commit heads/branch
 
 '
 
 test_expect_success 'push with config remote.*.push = HEAD' '
 
-	mk_test heads/local &&
+	mk_test testrepo heads/local &&
 	git checkout master &&
 	git branch -f local $the_commit &&
 	(
@@ -504,8 +512,8 @@ test_expect_success 'push with config remote.*.push = HEAD' '
 	git config remote.there.push HEAD &&
 	git config branch.master.remote there &&
 	git push &&
-	check_push_result $the_commit heads/master &&
-	check_push_result $the_first_commit heads/local
+	check_push_result testrepo $the_commit heads/master &&
+	check_push_result testrepo $the_first_commit heads/local
 '
 
 # clean up the cruft left with the previous one
@@ -514,12 +522,12 @@ git config --remove-section branch.master
 
 test_expect_success 'push with config remote.*.pushurl' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	git checkout master &&
 	git config remote.there.url test2repo &&
 	git config remote.there.pushurl testrepo &&
 	git push there &&
-	check_push_result $the_commit heads/master
+	check_push_result testrepo $the_commit heads/master
 '
 
 # clean up the cruft left with the previous one
@@ -527,19 +535,19 @@ git config --remove-section remote.there
 
 test_expect_success 'push with dry-run' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	(
 		cd testrepo &&
 		old_commit=$(git show-ref -s --verify refs/heads/master)
 	) &&
 	git push --dry-run testrepo &&
-	check_push_result $old_commit heads/master
+	check_push_result testrepo $old_commit heads/master
 '
 
 test_expect_success 'push updates local refs' '
 
-	mk_test heads/master &&
-	mk_child child &&
+	mk_test testrepo heads/master &&
+	mk_child testrepo child &&
 	(
 		cd child &&
 		git pull .. master &&
@@ -552,9 +560,9 @@ test_expect_success 'push updates local refs' '
 
 test_expect_success 'push updates up-to-date local refs' '
 
-	mk_test heads/master &&
-	mk_child child1 &&
-	mk_child child2 &&
+	mk_test testrepo heads/master &&
+	mk_child testrepo child1 &&
+	mk_child testrepo child2 &&
 	(cd child1 && git pull .. master && git push) &&
 	(
 		cd child2 &&
@@ -568,8 +576,8 @@ test_expect_success 'push updates up-to-date local refs' '
 
 test_expect_success 'push preserves up-to-date packed refs' '
 
-	mk_test heads/master &&
-	mk_child child &&
+	mk_test testrepo heads/master &&
+	mk_child testrepo child &&
 	(
 		cd child &&
 		git push &&
@@ -580,8 +588,8 @@ test_expect_success 'push preserves up-to-date packed refs' '
 
 test_expect_success 'push does not update local refs on failure' '
 
-	mk_test heads/master &&
-	mk_child child &&
+	mk_test testrepo heads/master &&
+	mk_child testrepo child &&
 	mkdir testrepo/.git/hooks &&
 	echo "#!/no/frobnication/today" >testrepo/.git/hooks/pre-receive &&
 	chmod +x testrepo/.git/hooks/pre-receive &&
@@ -597,7 +605,7 @@ test_expect_success 'push does not update local refs on failure' '
 
 test_expect_success 'allow deleting an invalid remote ref' '
 
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	rm -f testrepo/.git/objects/??/* &&
 	git push testrepo :refs/heads/master &&
 	(cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
@@ -605,7 +613,7 @@ test_expect_success 'allow deleting an invalid remote ref' '
 '
 
 test_expect_success 'pushing valid refs triggers post-receive and post-update hooks' '
-	mk_test_with_hooks heads/master heads/next &&
+	mk_test_with_hooks testrepo heads/master heads/next &&
 	orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
 	newmaster=$(git show-ref -s --verify refs/heads/master) &&
 	orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
@@ -641,7 +649,7 @@ test_expect_success 'pushing valid refs triggers post-receive and post-update ho
 '
 
 test_expect_success 'deleting dangling ref triggers hooks with correct args' '
-	mk_test_with_hooks heads/master &&
+	mk_test_with_hooks testrepo heads/master &&
 	rm -f testrepo/.git/objects/??/* &&
 	git push testrepo :refs/heads/master &&
 	(
@@ -670,7 +678,7 @@ test_expect_success 'deleting dangling ref triggers hooks with correct args' '
 '
 
 test_expect_success 'deletion of a non-existent ref is not fed to post-receive and post-update hooks' '
-	mk_test_with_hooks heads/master &&
+	mk_test_with_hooks testrepo heads/master &&
 	orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
 	newmaster=$(git show-ref -s --verify refs/heads/master) &&
 	git push testrepo master :refs/heads/nonexistent &&
@@ -702,7 +710,7 @@ test_expect_success 'deletion of a non-existent ref is not fed to post-receive a
 '
 
 test_expect_success 'deletion of a non-existent ref alone does trigger post-receive and post-update hooks' '
-	mk_test_with_hooks heads/master &&
+	mk_test_with_hooks testrepo heads/master &&
 	git push testrepo :refs/heads/nonexistent &&
 	(
 		cd testrepo/.git &&
@@ -722,7 +730,7 @@ test_expect_success 'deletion of a non-existent ref alone does trigger post-rece
 '
 
 test_expect_success 'mixed ref updates, deletes, invalid deletes trigger hooks with correct input' '
-	mk_test_with_hooks heads/master heads/next heads/pu &&
+	mk_test_with_hooks testrepo heads/master heads/next heads/pu &&
 	orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
 	newmaster=$(git show-ref -s --verify refs/heads/master) &&
 	orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
@@ -768,14 +776,14 @@ test_expect_success 'mixed ref updates, deletes, invalid deletes trigger hooks w
 '
 
 test_expect_success 'allow deleting a ref using --delete' '
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	(cd testrepo && git config receive.denyDeleteCurrent warn) &&
 	git push testrepo --delete master &&
 	(cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
 '
 
 test_expect_success 'allow deleting a tag using --delete' '
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	git tag -a -m dummy_message deltag heads/master &&
 	git push testrepo --tags &&
 	(cd testrepo && git rev-parse --verify -q refs/tags/deltag) &&
@@ -784,17 +792,17 @@ test_expect_success 'allow deleting a tag using --delete' '
 '
 
 test_expect_success 'push --delete without args aborts' '
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	test_must_fail git push testrepo --delete
 '
 
 test_expect_success 'push --delete refuses src:dest refspecs' '
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	test_must_fail git push testrepo --delete master:foo
 '
 
 test_expect_success 'warn on push to HEAD of non-bare repository' '
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	(
 		cd testrepo &&
 		git checkout master &&
@@ -805,7 +813,7 @@ test_expect_success 'warn on push to HEAD of non-bare repository' '
 '
 
 test_expect_success 'deny push to HEAD of non-bare repository' '
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	(
 		cd testrepo &&
 		git checkout master &&
@@ -815,7 +823,7 @@ test_expect_success 'deny push to HEAD of non-bare repository' '
 '
 
 test_expect_success 'allow push to HEAD of bare repository (bare)' '
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	(
 		cd testrepo &&
 		git checkout master &&
@@ -827,7 +835,7 @@ test_expect_success 'allow push to HEAD of bare repository (bare)' '
 '
 
 test_expect_success 'allow push to HEAD of non-bare repository (config)' '
-	mk_test heads/master &&
+	mk_test testrepo heads/master &&
 	(
 		cd testrepo &&
 		git checkout master &&
@@ -838,7 +846,7 @@ test_expect_success 'allow push to HEAD of non-bare repository (config)' '
 '
 
 test_expect_success 'fetch with branches' '
-	mk_empty &&
+	mk_empty testrepo &&
 	git branch second $the_first_commit &&
 	git checkout second &&
 	echo ".." > testrepo/.git/branches/branch1 &&
@@ -853,7 +861,7 @@ test_expect_success 'fetch with branches' '
 '
 
 test_expect_success 'fetch with branches containing #' '
-	mk_empty &&
+	mk_empty testrepo &&
 	echo "..#second" > testrepo/.git/branches/branch2 &&
 	(
 		cd testrepo &&
@@ -866,7 +874,7 @@ test_expect_success 'fetch with branches containing #' '
 '
 
 test_expect_success 'push with branches' '
-	mk_empty &&
+	mk_empty testrepo &&
 	git checkout second &&
 	echo "testrepo" > .git/branches/branch1 &&
 	git push branch1 &&
@@ -879,7 +887,7 @@ test_expect_success 'push with branches' '
 '
 
 test_expect_success 'push with branches containing #' '
-	mk_empty &&
+	mk_empty testrepo &&
 	echo "testrepo#branch3" > .git/branches/branch2 &&
 	git push branch2 &&
 	(
@@ -892,9 +900,9 @@ test_expect_success 'push with branches containing #' '
 '
 
 test_expect_success 'push into aliased refs (consistent)' '
-	mk_test heads/master &&
-	mk_child child1 &&
-	mk_child child2 &&
+	mk_test testrepo heads/master &&
+	mk_child testrepo child1 &&
+	mk_child testrepo child2 &&
 	(
 		cd child1 &&
 		git branch foo &&
@@ -914,9 +922,9 @@ test_expect_success 'push into aliased refs (consistent)' '
 '
 
 test_expect_success 'push into aliased refs (inconsistent)' '
-	mk_test heads/master &&
-	mk_child child1 &&
-	mk_child child2 &&
+	mk_test testrepo heads/master &&
+	mk_child testrepo child1 &&
+	mk_child testrepo child2 &&
 	(
 		cd child1 &&
 		git branch foo &&
@@ -941,9 +949,9 @@ test_expect_success 'push into aliased refs (inconsistent)' '
 '
 
 test_expect_success 'push requires --force to update lightweight tag' '
-	mk_test heads/master &&
-	mk_child child1 &&
-	mk_child child2 &&
+	mk_test testrepo heads/master &&
+	mk_child testrepo child1 &&
+	mk_child testrepo child2 &&
 	(
 		cd child1 &&
 		git tag Tag &&
@@ -962,7 +970,7 @@ test_expect_success 'push requires --force to update lightweight tag' '
 '
 
 test_expect_success 'push --porcelain' '
-	mk_empty &&
+	mk_empty testrepo &&
 	echo >.git/foo  "To testrepo" &&
 	echo >>.git/foo "*	refs/heads/master:refs/remotes/origin/master	[new branch]"  &&
 	echo >>.git/foo "Done" &&
@@ -977,13 +985,13 @@ test_expect_success 'push --porcelain' '
 '
 
 test_expect_success 'push --porcelain bad url' '
-	mk_empty &&
+	mk_empty testrepo &&
 	test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/master:refs/remotes/origin/master &&
 	test_must_fail grep -q Done .git/bar
 '
 
 test_expect_success 'push --porcelain rejected' '
-	mk_empty &&
+	mk_empty testrepo &&
 	git push testrepo refs/heads/master:refs/remotes/origin/master &&
 	(cd testrepo &&
 		git reset --hard origin/master^
@@ -997,7 +1005,7 @@ test_expect_success 'push --porcelain rejected' '
 '
 
 test_expect_success 'push --porcelain --dry-run rejected' '
-	mk_empty &&
+	mk_empty testrepo &&
 	git push testrepo refs/heads/master:refs/remotes/origin/master &&
 	(cd testrepo &&
 		git reset --hard origin/master
@@ -1012,25 +1020,25 @@ test_expect_success 'push --porcelain --dry-run rejected' '
 '
 
 test_expect_success 'push --prune' '
-	mk_test heads/master heads/second heads/foo heads/bar &&
+	mk_test testrepo heads/master heads/second heads/foo heads/bar &&
 	git push --prune testrepo &&
-	check_push_result $the_commit heads/master &&
-	check_push_result $the_first_commit heads/second &&
-	! check_push_result $the_first_commit heads/foo heads/bar
+	check_push_result testrepo $the_commit heads/master &&
+	check_push_result testrepo $the_first_commit heads/second &&
+	! check_push_result testrepo $the_first_commit heads/foo heads/bar
 '
 
 test_expect_success 'push --prune refspec' '
-	mk_test tmp/master tmp/second tmp/foo tmp/bar &&
+	mk_test testrepo tmp/master tmp/second tmp/foo tmp/bar &&
 	git push --prune testrepo "refs/heads/*:refs/tmp/*" &&
-	check_push_result $the_commit tmp/master &&
-	check_push_result $the_first_commit tmp/second &&
-	! check_push_result $the_first_commit tmp/foo tmp/bar
+	check_push_result testrepo $the_commit tmp/master &&
+	check_push_result testrepo $the_first_commit tmp/second &&
+	! check_push_result testrepo $the_first_commit tmp/foo tmp/bar
 '
 
 for configsection in transfer receive
 do
 	test_expect_success "push to update a ref hidden by $configsection.hiderefs" '
-		mk_test heads/master hidden/one hidden/two hidden/three &&
+		mk_test testrepo heads/master hidden/one hidden/two hidden/three &&
 		(
 			cd testrepo &&
 			git config $configsection.hiderefs refs/hidden
@@ -1038,32 +1046,32 @@ do
 
 		# push to unhidden ref succeeds normally
 		git push testrepo master:refs/heads/master &&
-		check_push_result $the_commit heads/master &&
+		check_push_result testrepo $the_commit heads/master &&
 
 		# push to update a hidden ref should fail
 		test_must_fail git push testrepo master:refs/hidden/one &&
-		check_push_result $the_first_commit hidden/one &&
+		check_push_result testrepo $the_first_commit hidden/one &&
 
 		# push to delete a hidden ref should fail
 		test_must_fail git push testrepo :refs/hidden/two &&
-		check_push_result $the_first_commit hidden/two &&
+		check_push_result testrepo $the_first_commit hidden/two &&
 
 		# idempotent push to update a hidden ref should fail
 		test_must_fail git push testrepo $the_first_commit:refs/hidden/three &&
-		check_push_result $the_first_commit hidden/three
+		check_push_result testrepo $the_first_commit hidden/three
 	'
 done
 
 test_expect_success 'fetch exact SHA1' '
-	mk_test heads/master hidden/one &&
+	mk_test testrepo heads/master hidden/one &&
 	git push testrepo master:refs/hidden/one &&
 	(
 		cd testrepo &&
 		git config transfer.hiderefs refs/hidden
 	) &&
-	check_push_result $the_commit hidden/one &&
+	check_push_result testrepo $the_commit hidden/one &&
 
-	mk_child child &&
+	mk_child testrepo child &&
 	(
 		cd child &&
 
-- 
1.8.2.141.g3797f84

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 4/6] remote.c: introduce a way to have different remotes for fetch/push
  2013-03-28 13:26 [PATCH v4 0/6] Support triangular workflows Ramkumar Ramachandra
                   ` (2 preceding siblings ...)
  2013-03-28 13:26 ` [PATCH 3/6] t5516 (fetch-push): drop implicit arguments from helper functions Ramkumar Ramachandra
@ 2013-03-28 13:26 ` Ramkumar Ramachandra
  2013-03-28 13:26 ` [PATCH 5/6] remote.c: introduce remote.pushdefault Ramkumar Ramachandra
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-28 13:26 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jeff King, Jonathan Nieder

Currently, do_push() in push.c calls remote_get(), which gets the
configured remote for fetching and pushing.  Replace this call with a
call to pushremote_get() instead, a new function that will return the
remote configured specifically for pushing.  This function tries to
work with the string pushremote_name, before falling back to the
codepath of remote_get().  This patch has no visible impact, but
serves to enable future patches to introduce configuration variables
to set pushremote_name.  For example, you can now do the following in
handle_config():

    if (!strcmp(key, "remote.pushdefault"))
       git_config_string(&pushremote_name, key, value);

Then, pushes will automatically go to the remote specified by
remote.pushdefault.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 builtin/push.c |  2 +-
 remote.c       | 25 +++++++++++++++++++++----
 remote.h       |  1 +
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/builtin/push.c b/builtin/push.c
index 42b129d..d447a80 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -322,7 +322,7 @@ static int push_with_options(struct transport *transport, int flags)
 static int do_push(const char *repo, int flags)
 {
 	int i, errs;
-	struct remote *remote = remote_get(repo);
+	struct remote *remote = pushremote_get(repo);
 	const char **url;
 	int url_nr;
 
diff --git a/remote.c b/remote.c
index 02e6c4c..b733aec 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 *pushremote_name;
 static int explicit_default_remote_name;
 
 static struct rewrites rewrites;
@@ -670,17 +671,21 @@ static int valid_remote_nick(const char *name)
 	return !strchr(name, '/'); /* no slash */
 }
 
-struct remote *remote_get(const char *name)
+static struct remote *remote_get_1(const char *name, const char *pushremote_name)
 {
 	struct remote *ret;
 	int name_given = 0;
 
-	read_config();
 	if (name)
 		name_given = 1;
 	else {
-		name = default_remote_name;
-		name_given = explicit_default_remote_name;
+		if (pushremote_name) {
+			name = pushremote_name;
+			name_given = 1;
+		} else {
+			name = default_remote_name;
+			name_given = explicit_default_remote_name;
+		}
 	}
 
 	ret = make_remote(name, 0);
@@ -699,6 +704,18 @@ struct remote *remote_get(const char *name)
 	return ret;
 }
 
+struct remote *remote_get(const char *name)
+{
+	read_config();
+	return remote_get_1(name, NULL);
+}
+
+struct remote *pushremote_get(const char *name)
+{
+	read_config();
+	return remote_get_1(name, pushremote_name);
+}
+
 int remote_is_configured(const char *name)
 {
 	int i;
diff --git a/remote.h b/remote.h
index f7b08f1..5fe5f53 100644
--- a/remote.h
+++ b/remote.h
@@ -51,6 +51,7 @@ struct remote {
 };
 
 struct remote *remote_get(const char *name);
+struct remote *pushremote_get(const char *name);
 int remote_is_configured(const char *name);
 
 typedef int each_remote_fn(struct remote *remote, void *priv);
-- 
1.8.2.141.g3797f84

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 5/6] remote.c: introduce remote.pushdefault
  2013-03-28 13:26 [PATCH v4 0/6] Support triangular workflows Ramkumar Ramachandra
                   ` (3 preceding siblings ...)
  2013-03-28 13:26 ` [PATCH 4/6] remote.c: introduce a way to have different remotes for fetch/push Ramkumar Ramachandra
@ 2013-03-28 13:26 ` Ramkumar Ramachandra
  2013-03-28 13:26 ` [PATCH 6/6] remote.c: introduce branch.<name>.pushremote Ramkumar Ramachandra
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-28 13:26 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jeff King, Jonathan Nieder

This new configuration variable defines the default remote to push to,
and overrides `branch.<name>.remote` for all branches.  It is useful
in the typical triangular-workflow setup, where the remote you're
fetching from is different from the remote you're pushing to.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 Documentation/config.txt | 13 ++++++++++---
 remote.c                 |  7 +++++++
 t/t5516-fetch-push.sh    | 12 ++++++++++++
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index c1f435f..dd78171 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -727,9 +727,12 @@ branch.autosetuprebase::
 	This option defaults to never.
 
 branch.<name>.remote::
-	When in branch <name>, it tells 'git fetch' and 'git push' which
-	remote to fetch from/push to.  It defaults to `origin` if no remote is
-	configured. `origin` is also used if you are not on any branch.
+	When on branch <name>, it tells 'git fetch' and 'git push'
+	which remote to fetch from/push to.  The remote to push to
+	may be overridden 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.
 
 branch.<name>.merge::
 	Defines, together with branch.<name>.remote, the upstream branch
@@ -1898,6 +1901,10 @@ receive.updateserverinfo::
 	If set to true, git-receive-pack will run git-update-server-info
 	after receiving data from git-push and updating refs.
 
+remote.pushdefault::
+	The remote to push to by default.  Overrides
+	`branch.<name>.remote` for all branches.
+
 remote.<name>.url::
 	The URL of a remote repository.  See linkgit:git-fetch[1] or
 	linkgit:git-push[1].
diff --git a/remote.c b/remote.c
index b733aec..49c4b8b 100644
--- a/remote.c
+++ b/remote.c
@@ -389,9 +389,16 @@ static int handle_config(const char *key, const char *value, void *cb)
 			add_instead_of(rewrite, xstrdup(value));
 		}
 	}
+
 	if (prefixcmp(key,  "remote."))
 		return 0;
 	name = key + 7;
+
+	/* Handle remote.* variables */
+	if (!strcmp(name, "pushdefault"))
+		return git_config_string(&pushremote_name, key, value);
+
+	/* Handle remote.<name>.* variables */
 	if (*name == '/') {
 		warning("Config remote shorthand cannot begin with '/': %s",
 			name);
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 94e0189..ac1ec9d 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -520,6 +520,18 @@ test_expect_success 'push with config remote.*.push = HEAD' '
 git config --remove-section remote.there
 git config --remove-section branch.master
 
+test_expect_success 'push with remote.pushdefault' '
+	mk_test up_repo heads/frotz &&
+	mk_test down_repo heads/master &&
+	test_config remote.up.url up_repo &&
+	test_config remote.down.url down_repo &&
+	test_config branch.master.remote up &&
+	test_config remote.pushdefault down &&
+	git push &&
+	test_must_fail check_push_result up_repo $the_commit heads/master &&
+	check_push_result down_repo $the_commit heads/master
+'
+
 test_expect_success 'push with config remote.*.pushurl' '
 
 	mk_test testrepo heads/master &&
-- 
1.8.2.141.g3797f84

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 6/6] remote.c: introduce branch.<name>.pushremote
  2013-03-28 13:26 [PATCH v4 0/6] Support triangular workflows Ramkumar Ramachandra
                   ` (4 preceding siblings ...)
  2013-03-28 13:26 ` [PATCH 5/6] remote.c: introduce remote.pushdefault Ramkumar Ramachandra
@ 2013-03-28 13:26 ` Ramkumar Ramachandra
  2013-03-28 15:02 ` [PATCH v4 0/6] Support triangular workflows Junio C Hamano
  2013-03-28 15:35 ` Jeff King
  7 siblings, 0 replies; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-28 13:26 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jeff King, Jonathan Nieder

This new configuration variable overrides `remote.pushdefault` and
`branch.<name>.remote` for pushes.  When you pull from one
place (e.g. your upstream) and push to another place (e.g. your own
publishing repository), 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 <artagnon@gmail.com>
---
 Documentation/config.txt | 19 +++++++++++++++----
 remote.c                 |  4 ++++
 t/t5516-fetch-push.sh    | 15 +++++++++++++++
 3 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index dd78171..ec579c5 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -730,9 +730,19 @@ branch.<name>.remote::
 	When on branch <name>, it tells 'git fetch' and 'git push'
 	which remote to fetch from/push to.  The remote to push to
 	may be overridden 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
+	overridden by `branch.<name>.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.<name>.pushremote::
+	When on branch <name>, it overrides `branch.<name>.remote` for
+	pushing.  It also overrides `remote.pushdefault` for pushing
+	from branch <name>.  When you pull from one place (e.g. your
+	upstream) and push to another place (e.g. your own publishing
+	repository), 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.<name>.merge::
 	Defines, together with branch.<name>.remote, the upstream branch
@@ -1903,7 +1913,8 @@ receive.updateserverinfo::
 
 remote.pushdefault::
 	The remote to push to by default.  Overrides
-	`branch.<name>.remote` for all branches.
+	`branch.<name>.remote` for all branches, and is overridden by
+	`branch.<name>.pushremote` for specific branches.
 
 remote.<name>.url::
 	The URL of a remote repository.  See linkgit:git-fetch[1] or
diff --git a/remote.c b/remote.c
index 49c4b8b..e89b1b7 100644
--- a/remote.c
+++ b/remote.c
@@ -364,6 +364,10 @@ 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)
+				if (git_config_string(&pushremote_name, key, value))
+					return -1;
 		} else if (!strcmp(subkey, ".merge")) {
 			if (!value)
 				return config_error_nonbool(key);
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index ac1ec9d..13028a4 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -542,6 +542,21 @@ test_expect_success 'push with config remote.*.pushurl' '
 	check_push_result testrepo $the_commit heads/master
 '
 
+test_expect_success 'push with config branch.*.pushremote' '
+	mk_test up_repo heads/frotz &&
+	mk_test side_repo heads/quux &&
+	mk_test down_repo heads/master &&
+	test_config remote.up.url up_repo &&
+	test_config remote.pushdefault side_repo &&
+	test_config remote.down.url down_repo &&
+	test_config branch.master.remote up &&
+	test_config branch.master.pushremote down &&
+	git push &&
+	test_must_fail check_push_result up_repo $the_commit heads/master &&
+	test_must_fail check_push_result side_repo $the_commit heads/master &&
+	check_push_result down_repo $the_commit heads/master
+'
+
 # clean up the cruft left with the previous one
 git config --remove-section remote.there
 
-- 
1.8.2.141.g3797f84

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/6] Support triangular workflows
  2013-03-28 13:26 [PATCH v4 0/6] Support triangular workflows Ramkumar Ramachandra
                   ` (5 preceding siblings ...)
  2013-03-28 13:26 ` [PATCH 6/6] remote.c: introduce branch.<name>.pushremote Ramkumar Ramachandra
@ 2013-03-28 15:02 ` Junio C Hamano
  2013-03-28 15:35 ` Jeff King
  7 siblings, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2013-03-28 15:02 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List, Jeff King, Jonathan Nieder

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> The changes in this round are:
>
> 1. Peff submitted a patch to squash into [3/6].  Since his patch
>    essentially reverts mine, I've blamed him for the change.
>
> 2. Peff suggested a code movement in [5/6] to make things flow more
>    naturally.
>
> 3. Jonathan suggested a better test description in [2/6].
>
> 4. Junio suggested a minor documentation update in [6/6].
>
> My build of git has had this feature for two weeks now (since the
> first iteration), and I'm very happy with it.

Will take a look; thanks for a reroll.

We may need a bit of adjustment to the longer term plan for the
push.default topic, as I expect we will have this feature a lot
sooner (e.g. perhaps in 1.8.4) than we will switch the push default
to "simple".  The description of simple and upstream still is
written around the "you push to and pull from the same place", and
may need to be updated to explain "what happens if you are employing
a triangular workflow?"  Or it could turn out that triangular people may be better
served by a push.default different from simple or upstream.

Or it may turn out that we do not need any change to what is queued
on the push-2.0-default-to-simple topic (I haven't thought things
through).

It is not urgent, but please start thinking about how you can help,
now you introduced the triangular stuff.

Thanks.

> Jeff King (1):
>   t5516 (fetch-push): drop implicit arguments from helper functions
>
> Ramkumar Ramachandra (5):
>   remote.c: simplify a bit of code using git_config_string()
>   t5516 (fetch-push): update test description
>   remote.c: introduce a way to have different remotes for fetch/push
>   remote.c: introduce remote.pushdefault
>   remote.c: introduce branch.<name>.pushremote
>
>  Documentation/config.txt |  24 +++-
>  builtin/push.c           |   2 +-
>  remote.c                 |  41 ++++--
>  remote.h                 |   1 +
>  t/t5516-fetch-push.sh    | 316 +++++++++++++++++++++++++++--------------------
>  5 files changed, 238 insertions(+), 146 deletions(-)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/6] Support triangular workflows
  2013-03-28 13:26 [PATCH v4 0/6] Support triangular workflows Ramkumar Ramachandra
                   ` (6 preceding siblings ...)
  2013-03-28 15:02 ` [PATCH v4 0/6] Support triangular workflows Junio C Hamano
@ 2013-03-28 15:35 ` Jeff King
  2013-03-28 16:54   ` Junio C Hamano
  2013-03-31 20:51   ` Ramkumar Ramachandra
  7 siblings, 2 replies; 24+ messages in thread
From: Jeff King @ 2013-03-28 15:35 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List, Junio C Hamano, Jonathan Nieder

On Thu, Mar 28, 2013 at 06:56:36PM +0530, Ramkumar Ramachandra wrote:

> Jeff King (1):
>   t5516 (fetch-push): drop implicit arguments from helper functions
> 
> Ramkumar Ramachandra (5):
>   remote.c: simplify a bit of code using git_config_string()
>   t5516 (fetch-push): update test description
>   remote.c: introduce a way to have different remotes for fetch/push
>   remote.c: introduce remote.pushdefault
>   remote.c: introduce branch.<name>.pushremote

Thanks, this iteration looks pretty good. I have one minor nit, which is
that the tests in patches 5 and 6 do things like:

> +	git push &&
> +	test_must_fail check_push_result up_repo $the_commit heads/master &&
> +	check_push_result down_repo $the_commit heads/master

Using test_must_fail here caught my eye, because usually it is meant to
check failure of a single git command. When it (or "!", for that matter)
is used with a compound function, you end up losing robustness in corner
cases.

For example, imagine your function is:

  check_foo() {
          cd "$1" &&
          git foo
  }

and you expect in some cases that "git foo" will succeed and in some
cases it will fail. In the affirmative case (running "check_foo"), this
is robust; if any of the steps fails, the test fails.

But if you run the negative case ("test_must_fail check_foo"), you will
also fail if any of the preparatory steps fail. I.e., you wanted to say:

  cd "$1" && test_must_fail git foo

but you actually said (applying De Morgan's laws):

  test_must_fail cd "$1" || test_must_fail git foo

Now we probably don't expect the "cd" to fail here, but of course the
other steps can be more complicated, too. In your case, I think the
effect you are looking for is that "heads/master != $the_commit". But
note that we would also fail if "git fsck" fails in the pushed
repository, which is not what we want.

Sometimes it's annoyingly verbose to break down a compound function. But
I think in this case, you can make your tests more robust by just
checking the affirmative that the ref is still where we expect it to be,
like:

  check_push_result up_repo $the_first_commit heads/master

Sorry if that was a bit long-winded. I think that practically speaking,
it is not a likely source of problems in this case. But it's an
anti-pattern in our tests that I think is worth mentioning.

-Peff

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/6] Support triangular workflows
  2013-03-28 15:35 ` Jeff King
@ 2013-03-28 16:54   ` Junio C Hamano
  2013-03-31 20:54     ` Ramkumar Ramachandra
  2013-03-31 20:51   ` Ramkumar Ramachandra
  1 sibling, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2013-03-28 16:54 UTC (permalink / raw)
  To: Jeff King; +Cc: Ramkumar Ramachandra, Git List, Jonathan Nieder

Jeff King <peff@peff.net> writes:

> Sometimes it's annoyingly verbose to break down a compound function. But
> I think in this case, you can make your tests more robust by just
> checking the affirmative that the ref is still where we expect it to be,
> like:
>
>   check_push_result up_repo $the_first_commit heads/master
>
> Sorry if that was a bit long-winded. I think that practically speaking,
> it is not a likely source of problems in this case. But it's an
> anti-pattern in our tests that I think is worth mentioning.

Thanks.  That is one of the reasons why we do not want to see too
many custom test helper functions.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/6] Support triangular workflows
  2013-03-28 15:35 ` Jeff King
  2013-03-28 16:54   ` Junio C Hamano
@ 2013-03-31 20:51   ` Ramkumar Ramachandra
  2013-03-31 21:43     ` Jeff King
  1 sibling, 1 reply; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-31 20:51 UTC (permalink / raw)
  To: Jeff King; +Cc: Git List, Junio C Hamano, Jonathan Nieder

Jeff King wrote:
> [...]

So, you're saying: don't test compound statements for failure, since
anything in the chain could fail and propagate failure.  I should only
test simple git-foo commands for failure?

> Sometimes it's annoyingly verbose to break down a compound function. But
> I think in this case, you can make your tests more robust by just
> checking the affirmative that the ref is still where we expect it to be,
> like:
>
>   check_push_result up_repo $the_first_commit heads/master

Doesn't that change the meaning of the test though?  I really like how
the original tests read.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/6] Support triangular workflows
  2013-03-28 16:54   ` Junio C Hamano
@ 2013-03-31 20:54     ` Ramkumar Ramachandra
  2013-04-01  1:56       ` Junio C Hamano
  0 siblings, 1 reply; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-31 20:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, Git List, Jonathan Nieder

Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>> [...]
> Thanks.  That is one of the reasons why we do not want to see too
> many custom test helper functions.

I noticed that you queued my original series without modification in
rr/triangle.  Should I submit a re-roll with Peff's suggestion
incorporated?

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/6] Support triangular workflows
  2013-03-31 20:51   ` Ramkumar Ramachandra
@ 2013-03-31 21:43     ` Jeff King
  2013-04-01  1:50       ` Junio C Hamano
  0 siblings, 1 reply; 24+ messages in thread
From: Jeff King @ 2013-03-31 21:43 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List, Junio C Hamano, Jonathan Nieder

On Mon, Apr 01, 2013 at 02:21:22AM +0530, Ramkumar Ramachandra wrote:

> Jeff King wrote:
> > [...]
> 
> So, you're saying: don't test compound statements for failure, since
> anything in the chain could fail and propagate failure.  I should only
> test simple git-foo commands for failure?

Right.

> > Sometimes it's annoyingly verbose to break down a compound function. But
> > I think in this case, you can make your tests more robust by just
> > checking the affirmative that the ref is still where we expect it to be,
> > like:
> >
> >   check_push_result up_repo $the_first_commit heads/master
> 
> Doesn't that change the meaning of the test though?  I really like how
> the original tests read.

Does it? I thought the original was:

  test_must_fail check_push_result up_repo $the_commit heads/master

which is checking that we did _not_ push $the_commit to up_repo.
Checking that without a negative means confirming that what _used_ to be
there is still there, which is $the_first_commit.

But I didn't actually run it, so I might be wrong about what is supposed
to be there after the (lack of) push.

-Peff

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/6] Support triangular workflows
  2013-03-31 21:43     ` Jeff King
@ 2013-04-01  1:50       ` Junio C Hamano
  0 siblings, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2013-04-01  1:50 UTC (permalink / raw)
  To: Jeff King; +Cc: Ramkumar Ramachandra, Git List, Jonathan Nieder

Jeff King <peff@peff.net> writes:

> On Mon, Apr 01, 2013 at 02:21:22AM +0530, Ramkumar Ramachandra wrote:
>
>> Jeff King wrote:
>> > [...]
>> 
>> So, you're saying: don't test compound statements for failure, since
>> anything in the chain could fail and propagate failure.  I should only
>> test simple git-foo commands for failure?
>
> Right.

I think another thing to keep in mind is that "test_must_fail" is
used only to check for an expected failure from git-foo commands,
not for a random command (or sequence of commands).

The primary point of test_must_fail is not to declare _any_ failure
as "Oh, good, I wanted see it to fail and it returned non-zero exit
status so I am happy", but exclude uncontrolled failures, by saying
"Yuck, it returned non-zero exit status, but it died by signal
(e.g. SEGV), which is not the way I wanted to see it die".

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/6] Support triangular workflows
  2013-03-31 20:54     ` Ramkumar Ramachandra
@ 2013-04-01  1:56       ` Junio C Hamano
  2013-04-01  3:36         ` Junio C Hamano
  2013-04-01  5:07         ` Junio C Hamano
  0 siblings, 2 replies; 24+ messages in thread
From: Junio C Hamano @ 2013-04-01  1:56 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Jeff King, Git List, Jonathan Nieder

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> Junio C Hamano wrote:
>> Jeff King <peff@peff.net> writes:
>>> [...]
>> Thanks.  That is one of the reasons why we do not want to see too
>> many custom test helper functions.
>
> I noticed that you queued my original series without modification in
> rr/triangle.  Should I submit a re-roll with Peff's suggestion
> incorporated?

If you want the topic to make progress, yes.

The only reason a topic is queued in 'pu' is to let me not pay
attention to it, without risking to forget about it completely ;-).

The topics on 'pu' have potential to be a useful change even though
they are far from ready for 'next'.  By queuing on 'pu', rather than
just letting them sit in the mail archive and relying on the author
to send follow-ups, I can send out "what happened to this topic?"
inquiries from time to time, without paying constant attention to
them.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/6] Support triangular workflows
  2013-04-01  1:56       ` Junio C Hamano
@ 2013-04-01  3:36         ` Junio C Hamano
  2013-04-01  5:07         ` Junio C Hamano
  1 sibling, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2013-04-01  3:36 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Jeff King, Git List, Jonathan Nieder

Junio C Hamano <gitster@pobox.com> writes:

> The only reason a topic is queued in 'pu' is to let me not pay
> attention to it, without risking to forget about it completely ;-).
>
> The topics on 'pu' have potential to be a useful change even though
> they are far from ready for 'next'.

That's not "even though" but should have been "even when".
Sometimes when I feel a topic is already of 'next' quality, the
author suggests that a reroll is coming, and I hold such a topic
off.

Also, inverse is not true, as always.  Some topics may not be queued
in 'pu' when I push a day's integration results out, but that does
not mean they do not have potential to be useful.  They may not be
in 'pu' because I didn't have enough time to get around to them, or
because there was discussion ongoing and I saw the author was
actively responding to the comments, relieving me from having to
keep an eye on the topic at all until the dust settled without even
queueing it on 'pu'.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/6] Support triangular workflows
  2013-04-01  1:56       ` Junio C Hamano
  2013-04-01  3:36         ` Junio C Hamano
@ 2013-04-01  5:07         ` Junio C Hamano
  2013-04-01  5:35           ` Junio C Hamano
  1 sibling, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2013-04-01  5:07 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Jeff King, Git List, Jonathan Nieder

Junio C Hamano <gitster@pobox.com> writes:

> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>
>> Junio C Hamano wrote:
>>> Jeff King <peff@peff.net> writes:
>>>> [...]
>>> Thanks.  That is one of the reasons why we do not want to see too
>>> many custom test helper functions.
>>
>> I noticed that you queued my original series without modification in
>> rr/triangle.  Should I submit a re-roll with Peff's suggestion
>> incorporated?
>
> If you want the topic to make progress, yes.

By the way, this series seems to break a few tests in the test
suite, both as a standalone topic branch and as part of the 'pu'.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/6] Support triangular workflows
  2013-04-01  5:07         ` Junio C Hamano
@ 2013-04-01  5:35           ` Junio C Hamano
  0 siblings, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2013-04-01  5:35 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Jeff King, Git List, Jonathan Nieder

Junio C Hamano <gitster@pobox.com> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>>
>>> Junio C Hamano wrote:
>>>> Jeff King <peff@peff.net> writes:
>>>>> [...]
>>>> Thanks.  That is one of the reasons why we do not want to see too
>>>> many custom test helper functions.
>>>
>>> I noticed that you queued my original series without modification in
>>> rr/triangle.  Should I submit a re-roll with Peff's suggestion
>>> incorporated?
>>
>> If you want the topic to make progress, yes.
>
> By the way, this series seems to break a few tests in the test
> suite,...

I suspect this could be interaction with push-default change near
the tip of 'pu'.  Setting push.default explicitly to matching in the
test may be necessary.

Also the t5516 is involved in in-flight churns, so there could be
some merge mixups.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 1/6] remote.c: simplify a bit of code using git_config_string()
  2013-04-02  7:40 [PATCH 0/6] Re-roll rr/triangle Ramkumar Ramachandra
@ 2013-04-02  7:40 ` Ramkumar Ramachandra
  0 siblings, 0 replies; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-04-02  7:40 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jeff King, Jonathan Nieder

A small segment where handle_config() parses the branch.remote
configuration variable can be simplified using git_config_string().

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 remote.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/remote.c b/remote.c
index ca1edd9..34ddc5b 100644
--- a/remote.c
+++ b/remote.c
@@ -357,9 +357,8 @@ static int handle_config(const char *key, const char *value, void *cb)
 			return 0;
 		branch = make_branch(name, subkey - name);
 		if (!strcmp(subkey, ".remote")) {
-			if (!value)
-				return config_error_nonbool(key);
-			branch->remote_name = xstrdup(value);
+			if (git_config_string(&branch->remote_name, key, value))
+				return -1;
 			if (branch == current_branch) {
 				default_remote_name = branch->remote_name;
 				explicit_default_remote_name = 1;
-- 
1.8.2.363.g901f5bc

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 1/6] remote.c: simplify a bit of code using git_config_string()
  2013-03-22  7:52 ` [PATCH 1/6] remote.c: simplify a bit of code using git_config_string() Ramkumar Ramachandra
@ 2013-03-22 18:26   ` Jonathan Nieder
  0 siblings, 0 replies; 24+ messages in thread
From: Jonathan Nieder @ 2013-03-22 18:26 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List, Junio C Hamano, Jeff King

Ramkumar Ramachandra wrote:

> A small segment where handle_config() parses the branch.remote
> configuration variable can be simplified using git_config_string().

Looks correct.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 1/6] remote.c: simplify a bit of code using git_config_string()
  2013-03-22  7:52 [PATCH v3 0/6] Support triangular workflows Ramkumar Ramachandra
@ 2013-03-22  7:52 ` Ramkumar Ramachandra
  2013-03-22 18:26   ` Jonathan Nieder
  0 siblings, 1 reply; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-22  7:52 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jeff King, Jonathan Nieder

A small segment where handle_config() parses the branch.remote
configuration variable can be simplified using git_config_string().

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 remote.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/remote.c b/remote.c
index e53a6eb..5bd59bb 100644
--- a/remote.c
+++ b/remote.c
@@ -356,9 +356,8 @@ static int handle_config(const char *key, const char *value, void *cb)
 			return 0;
 		branch = make_branch(name, subkey - name);
 		if (!strcmp(subkey, ".remote")) {
-			if (!value)
-				return config_error_nonbool(key);
-			branch->remote_name = xstrdup(value);
+			if (git_config_string(&branch->remote_name, key, value))
+				return -1;
 			if (branch == current_branch) {
 				default_remote_name = branch->remote_name;
 				explicit_default_remote_name = 1;
-- 
1.8.2.62.ga35d936.dirty

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 1/6] remote.c: simplify a bit of code using git_config_string()
  2013-03-20 18:07   ` Jonathan Nieder
@ 2013-03-20 18:12     ` Ramkumar Ramachandra
  0 siblings, 0 replies; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-20 18:12 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Git List, Junio C Hamano, Jeff King, Eric Sunshine

Jonathan Nieder wrote:
> Ramkumar Ramachandra wrote:
>
>> --- a/remote.c
>> +++ b/remote.c
>> @@ -356,9 +356,7 @@ static int handle_config(const char *key, const char *value, void *cb)
>>                       return 0;
>>               branch = make_branch(name, subkey - name);
>>               if (!strcmp(subkey, ".remote")) {
>> -                     if (!value)
>> -                             return config_error_nonbool(key);
>> -                     branch->remote_name = xstrdup(value);
>> +                     git_config_string(&branch->remote_name, key, value);
>
> Shouldn't this say
>
>                         if (git_config_string(&branch->remote_name, key, value))
>                                 return -1;
>
> or something?

Yes, and so should the instances in [5/6] and [6/6].  Thanks for catching it.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 1/6] remote.c: simplify a bit of code using git_config_string()
  2013-03-20 12:44 ` [PATCH 1/6] remote.c: simplify a bit of code using git_config_string() Ramkumar Ramachandra
@ 2013-03-20 18:07   ` Jonathan Nieder
  2013-03-20 18:12     ` Ramkumar Ramachandra
  0 siblings, 1 reply; 24+ messages in thread
From: Jonathan Nieder @ 2013-03-20 18:07 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List, Junio C Hamano, Jeff King, Eric Sunshine

Ramkumar Ramachandra wrote:

> --- a/remote.c
> +++ b/remote.c
> @@ -356,9 +356,7 @@ static int handle_config(const char *key, const char *value, void *cb)
>  			return 0;
>  		branch = make_branch(name, subkey - name);
>  		if (!strcmp(subkey, ".remote")) {
> -			if (!value)
> -				return config_error_nonbool(key);
> -			branch->remote_name = xstrdup(value);
> +			git_config_string(&branch->remote_name, key, value);

Shouldn't this say

			if (git_config_string(&branch->remote_name, key, value))
				return -1;

or something?

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 1/6] remote.c: simplify a bit of code using git_config_string()
  2013-03-20 12:44 [PATCH v2 0/6] Support triangular workflows Ramkumar Ramachandra
@ 2013-03-20 12:44 ` Ramkumar Ramachandra
  2013-03-20 18:07   ` Jonathan Nieder
  0 siblings, 1 reply; 24+ messages in thread
From: Ramkumar Ramachandra @ 2013-03-20 12:44 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jeff King, Eric Sunshine, Jonathan Nieder

A small segment where handle_config() parses the branch.remote
configuration variable can be simplified using git_config_string().

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 remote.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/remote.c b/remote.c
index e53a6eb..45b69d6 100644
--- a/remote.c
+++ b/remote.c
@@ -356,9 +356,7 @@ static int handle_config(const char *key, const char *value, void *cb)
 			return 0;
 		branch = make_branch(name, subkey - name);
 		if (!strcmp(subkey, ".remote")) {
-			if (!value)
-				return config_error_nonbool(key);
-			branch->remote_name = xstrdup(value);
+			git_config_string(&branch->remote_name, key, value);
 			if (branch == current_branch) {
 				default_remote_name = branch->remote_name;
 				explicit_default_remote_name = 1;
-- 
1.8.2

^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2013-04-02  7:39 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-28 13:26 [PATCH v4 0/6] Support triangular workflows Ramkumar Ramachandra
2013-03-28 13:26 ` [PATCH 1/6] remote.c: simplify a bit of code using git_config_string() Ramkumar Ramachandra
2013-03-28 13:26 ` [PATCH 2/6] t5516 (fetch-push): update test description Ramkumar Ramachandra
2013-03-28 13:26 ` [PATCH 3/6] t5516 (fetch-push): drop implicit arguments from helper functions Ramkumar Ramachandra
2013-03-28 13:26 ` [PATCH 4/6] remote.c: introduce a way to have different remotes for fetch/push Ramkumar Ramachandra
2013-03-28 13:26 ` [PATCH 5/6] remote.c: introduce remote.pushdefault Ramkumar Ramachandra
2013-03-28 13:26 ` [PATCH 6/6] remote.c: introduce branch.<name>.pushremote Ramkumar Ramachandra
2013-03-28 15:02 ` [PATCH v4 0/6] Support triangular workflows Junio C Hamano
2013-03-28 15:35 ` Jeff King
2013-03-28 16:54   ` Junio C Hamano
2013-03-31 20:54     ` Ramkumar Ramachandra
2013-04-01  1:56       ` Junio C Hamano
2013-04-01  3:36         ` Junio C Hamano
2013-04-01  5:07         ` Junio C Hamano
2013-04-01  5:35           ` Junio C Hamano
2013-03-31 20:51   ` Ramkumar Ramachandra
2013-03-31 21:43     ` Jeff King
2013-04-01  1:50       ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2013-04-02  7:40 [PATCH 0/6] Re-roll rr/triangle Ramkumar Ramachandra
2013-04-02  7:40 ` [PATCH 1/6] remote.c: simplify a bit of code using git_config_string() Ramkumar Ramachandra
2013-03-22  7:52 [PATCH v3 0/6] Support triangular workflows Ramkumar Ramachandra
2013-03-22  7:52 ` [PATCH 1/6] remote.c: simplify a bit of code using git_config_string() Ramkumar Ramachandra
2013-03-22 18:26   ` Jonathan Nieder
2013-03-20 12:44 [PATCH v2 0/6] Support triangular workflows Ramkumar Ramachandra
2013-03-20 12:44 ` [PATCH 1/6] remote.c: simplify a bit of code using git_config_string() Ramkumar Ramachandra
2013-03-20 18:07   ` Jonathan Nieder
2013-03-20 18:12     ` Ramkumar Ramachandra

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).