diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-11-25 12:48:26 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-11-26 10:05:04 -0800 |
commit | e6196ae10f6a05d74bae4542b6b675831f3b9c20 (patch) | |
tree | 15a3e52f955842ddf3cb42f48b74f7a0e67f8096 /t/t5505-remote.sh | |
parent | 652e759330da379a8e09e03bbf99e03c10c228cc (diff) | |
download | git-pw/remote-set-url-fetch.tar.gz |
remote: add --fetch and --both options to set-urlpw/remote-set-url-fetch
git remote set-url knew about the '--push' option to update just the
pushurl, but it does not have a similar option for "update fetch URL and
leave whatever was in place for the push URL".
This patch adds support for a '--fetch' option which implements that use
case in a backwards compatible way: if no --both, --push or --fetch
options are given, then the push URL is modified too if it was not set
before. This is the case since the push URL is implicitly based on the
fetch URL.
A '--both' option is added to make the command independent of previous
pushurl settings. For the --add and --delete set operations, it will
always set the push and/ or the fetch URLs. For the primary mode of
operation (without --add or --delete), it will drop pushurl as the
implicit push URL is the (fetch) URL.
The documentation has also been updated and a missing '--push' option
is added to the 'git remote -h' command.
Tests are also added to verify the documented behavior.
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5505-remote.sh')
-rwxr-xr-x | t/t5505-remote.sh | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index ac79dd915d..390281aa36 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -961,6 +961,59 @@ test_expect_success 'remote set-url --push zot' ' cmp expect actual ' +test_expect_success 'remote set-url --fetch zox' ' + git remote set-url --fetch someremote zox && + echo zox >expect && + echo "YYY" >>expect && + echo zot >>expect && + git config --get-all remote.someremote.url >actual && + echo "YYY" >>actual && + git config --get-all remote.someremote.pushurl >>actual && + cmp expect actual +' + +test_expect_success 'remote set-url --both foo' ' + git remote set-url --both someremote foo && + echo "YYY" >expect && + echo foo >>expect && + test_must_fail git config --get-all remote.someremote.pushurl >actual && + echo "YYY" >>actual && + git config --get-all remote.someremote.url >>actual && + cmp expect actual +' + +test_expect_success 'remote set-url --delete --push foo' ' + git remote set-url --delete --push someremote foo && + echo "YYY" >expect && + echo foo >>expect && + test_must_fail git config --get-all remote.someremote.pushurl >actual && + echo "YYY" >actual && + git config --get-all remote.someremote.url >>actual && + cmp expect actual +' + +test_expect_success 'remote set-url --push zot' ' + git remote set-url --push someremote zot && + echo zot >expect && + echo "YYY" >>expect && + echo foo >>expect && + git config --get-all remote.someremote.pushurl >actual && + echo "YYY" >>actual && + git config --get-all remote.someremote.url >>actual && + cmp expect actual +' + +test_expect_success 'remote set-url --fetch baz foo' ' + git remote set-url --fetch someremote baz foo && + echo zot >expect && + echo "YYY" >>expect && + echo baz >>expect && + git config --get-all remote.someremote.pushurl >actual && + echo "YYY" >>actual && + git config --get-all remote.someremote.url >>actual && + cmp expect actual +' + test_expect_success 'remote set-url --push qux zot' ' git remote set-url --push someremote qux zot && echo qux >expect && @@ -1091,6 +1144,78 @@ test_expect_success 'remote set-url --delete baz' ' cmp expect actual ' +test_expect_success 'remote set-url --fetch --add bar' ' + git remote set-url --fetch --add someremote bar && + echo ccc >expect && + echo "YYY" >>expect && + echo ccc >>expect && + echo bar >>expect && + git config --get-all remote.someremote.pushurl >actual && + echo "YYY" >>actual && + git config --get-all remote.someremote.url >>actual && + cmp expect actual +' + +test_expect_success 'remote set-url --both --add foo' ' + git remote set-url --both --add someremote foo && + echo ccc >expect && + echo foo >>expect && + echo "YYY" >>expect && + echo ccc >>expect && + echo bar >>expect && + echo foo >>expect && + git config --get-all remote.someremote.pushurl >actual && + echo "YYY" >>actual && + git config --get-all remote.someremote.url >>actual && + cmp expect actual +' + +test_expect_success 'remote set-url --both --delete ccc' ' + git remote set-url --both --delete someremote ccc && + echo foo >expect && + echo "YYY" >>expect && + echo bar >>expect && + echo foo >>expect && + git config --get-all remote.someremote.pushurl >actual && + echo "YYY" >>actual && + git config --get-all remote.someremote.url >>actual && + cmp expect actual +' + +test_expect_success 'remote set-url --fetch --delete bar' ' + git remote set-url --fetch --delete someremote bar && + echo foo >expect && + echo "YYY" >>expect && + echo foo >>expect && + git config --get-all remote.someremote.pushurl >actual && + echo "YYY" >>actual && + git config --get-all remote.someremote.url >>actual && + cmp expect actual +' + +test_expect_success 'remote set-url --push --add baz' ' + git remote set-url --push --add someremote baz && + echo foo >expect && + echo baz >>expect && + echo "YYY" >>expect && + echo foo >>expect && + git config --get-all remote.someremote.pushurl >actual && + echo "YYY" >>actual && + git config --get-all remote.someremote.url >>actual && + cmp expect actual +' + +test_expect_success 'remote set-url --push --delete foo' ' + git remote set-url --push --delete someremote foo && + echo baz >expect && + echo "YYY" >>expect && + echo foo >>expect && + git config --get-all remote.someremote.pushurl >actual && + echo "YYY" >>actual && + git config --get-all remote.someremote.url >>actual && + cmp expect actual +' + test_expect_success 'extra args: setup' ' # add a dummy origin so that this does not trigger failure git remote add origin . |