diff options
Diffstat (limited to 't/t5505-remote.sh')
-rwxr-xr-x | t/t5505-remote.sh | 84 |
1 files changed, 68 insertions, 16 deletions
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 1e192a2207..1f59960d90 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -28,7 +28,7 @@ tokens_match () { } check_remote_track () { - actual=$(git remote show "$1" | sed -n -e '$p') && + actual=$(git remote show "$1" | sed -e '1,/Tracked/d') && shift && tokens_match "$*" "$actual" } @@ -109,15 +109,17 @@ test_expect_success 'remove remote' ' cat > test/expect << EOF * remote origin - URL: $(pwd)/one/.git + URL: $(pwd)/one Remote branch merged with 'git pull' while on branch master master New remote branch (next fetch will store in remotes/origin) master Tracked remote branches - side master + side + master Local branches pushed with 'git push' - master:upstream +refs/tags/lastbackup + master:upstream + +refs/tags/lastbackup EOF test_expect_success 'show' ' @@ -140,13 +142,15 @@ test_expect_success 'show' ' cat > test/expect << EOF * remote origin - URL: $(pwd)/one/.git + URL: $(pwd)/one Remote branch merged with 'git pull' while on branch master master Tracked remote branches - master side + master + side Local branches pushed with 'git push' - master:upstream +refs/tags/lastbackup + master:upstream + +refs/tags/lastbackup EOF test_expect_success 'show -n' ' @@ -164,12 +168,12 @@ test_expect_success 'prune' ' git fetch origin && git remote prune origin && git rev-parse refs/remotes/origin/side2 && - ! git rev-parse refs/remotes/origin/side) + test_must_fail git rev-parse refs/remotes/origin/side) ' cat > test/expect << EOF Pruning origin -URL: $(pwd)/one/.git +URL: $(pwd)/one * [would prune] origin/side2 EOF @@ -179,7 +183,7 @@ test_expect_success 'prune --dry-run' ' (cd test && git remote prune --dry-run origin > output && git rev-parse refs/remotes/origin/side2 && - ! git rev-parse refs/remotes/origin/side && + test_must_fail git rev-parse refs/remotes/origin/side && (cd ../one && git branch -m side side2) && test_cmp expect output) @@ -188,16 +192,16 @@ test_expect_success 'prune --dry-run' ' test_expect_success 'add --mirror && prune' ' (mkdir mirror && cd mirror && - git init && + git init --bare && git remote add --mirror -f origin ../one) && (cd one && git branch -m side2 side) && (cd mirror && git rev-parse --verify refs/heads/side2 && - ! git rev-parse --verify refs/heads/side && + test_must_fail git rev-parse --verify refs/heads/side && git fetch origin && git remote prune origin && - ! git rev-parse --verify refs/heads/side2 && + test_must_fail git rev-parse --verify refs/heads/side2 && git rev-parse --verify refs/heads/side) ' @@ -212,10 +216,10 @@ test_expect_success 'add alt && prune' ' git branch -m side side2) && (cd alttst && git rev-parse --verify refs/remotes/origin/side && - ! git rev-parse --verify refs/remotes/origin/side2 && + test_must_fail git rev-parse --verify refs/remotes/origin/side2 && git fetch alt && git remote prune alt && - ! git rev-parse --verify refs/remotes/origin/side && + test_must_fail git rev-parse --verify refs/remotes/origin/side && git rev-parse --verify refs/remotes/origin/side2) ' @@ -320,8 +324,56 @@ test_expect_success '"remote show" does not show symbolic refs' ' test_expect_success 'reject adding remote with an invalid name' ' - ! git remote add some:url desired-name + test_must_fail git remote add some:url desired-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") + +' + +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 |