From bf98421a3363696f3b4c8aedc242bfaadc1ce6f6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 3 Nov 2008 19:26:18 +0100 Subject: Implement git remote rename The new rename subcommand does the followings: 1) Renames the remote.foo configuration section to remote.bar 2) Updates the remote.bar.fetch refspecs 3) Updates the branch.*.remote settings 4) Renames the tracking branches: renames the normal refs and rewrites the symrefs to point to the new refs. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t5505-remote.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 't') diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index c4380c7e32..0c956bad69 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -328,4 +328,19 @@ test_expect_success 'reject adding remote with an invalid name' ' ' +# The first three test if the tracking branches are properly renamed, +# the last two ones check if the config is updated. + +test_expect_success 'rename a remote' ' + + git clone one four && + (cd four && + git remote rename origin upstream && + rmdir .git/refs/remotes/origin && + test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" && + test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" && + test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" && + test "$(git config branch.master.remote)" = "upstream") + +' test_done -- cgit v1.2.1 From 1dd1239aa33ddd7f159cd183338ef6f71298e29a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 10 Nov 2008 21:43:01 +0100 Subject: git-remote rename: migrate from remotes/ and branches/ Remote definition that came from $GIT_DIR/remotes/nick and $GIT_DIR/branches/nick are migrated to [remotes "nick"] section in the configuration file. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t5505-remote.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 't') diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 0c956bad69..1f59960d90 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -343,4 +343,37 @@ test_expect_success 'rename a remote' ' test "$(git config branch.master.remote)" = "upstream") ' + +cat > remotes_origin << EOF +URL: $(pwd)/one +Push: refs/heads/master:refs/heads/upstream +Pull: refs/heads/master:refs/heads/origin +EOF + +test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' ' + git clone one five && + origin_url=$(pwd)/one && + (cd five && + git remote rm origin && + mkdir -p .git/remotes && + cat ../remotes_origin > .git/remotes/origin && + git remote rename origin origin && + ! test -f .git/remotes/origin && + test "$(git config remote.origin.url)" = "$origin_url" && + test "$(git config remote.origin.push)" = "refs/heads/master:refs/heads/upstream" && + test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin") +' + +test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' ' + git clone one six && + origin_url=$(pwd)/one && + (cd six && + git remote rm origin && + echo "$origin_url" > .git/branches/origin && + git remote rename origin origin && + ! test -f .git/branches/origin && + test "$(git config remote.origin.url)" = "$origin_url" && + test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin") +' + test_done -- cgit v1.2.1