X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Ft5505-remote.sh;h=4e69c907d810c5a82892f94f05374b824a003771;hb=20fc73e3b0bb2b115d88e54514db13ffaf11b025;hp=26920502093a98d4b5721f783e006de9d999792a;hpb=cb198b3b67feb2c0a6f22199ec14fa48d18ac1ce;p=git.git diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 269205020..4e69c907d 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -107,20 +107,23 @@ test_expect_success 'remove remote' ' ) ' -test_expect_success 'remove remote protects non-remote branches' ' +test_expect_success 'remove remote protects local branches' ' ( cd test && - (cat >expect1 <expect1 <expect2 <expect2 <actual1 && git branch foobranch && @@ -301,6 +304,84 @@ test_expect_success 'add --mirror && prune' ' git rev-parse --verify refs/heads/side) ' +test_expect_success 'add --mirror=fetch' ' + mkdir mirror-fetch && + git init mirror-fetch/parent && + (cd mirror-fetch/parent && + test_commit one) && + git init --bare mirror-fetch/child && + (cd mirror-fetch/child && + git remote add --mirror=fetch -f parent ../parent) +' + +test_expect_success 'fetch mirrors act as mirrors during fetch' ' + (cd mirror-fetch/parent && + git branch new && + git branch -m master renamed + ) && + (cd mirror-fetch/child && + git fetch parent && + git rev-parse --verify refs/heads/new && + git rev-parse --verify refs/heads/renamed + ) +' + +test_expect_success 'fetch mirrors can prune' ' + (cd mirror-fetch/child && + git remote prune parent && + test_must_fail git rev-parse --verify refs/heads/master + ) +' + +test_expect_success 'fetch mirrors do not act as mirrors during push' ' + (cd mirror-fetch/parent && + git checkout HEAD^0 + ) && + (cd mirror-fetch/child && + git branch -m renamed renamed2 && + git push parent + ) && + (cd mirror-fetch/parent && + git rev-parse --verify renamed && + test_must_fail git rev-parse --verify refs/heads/renamed2 + ) +' + +test_expect_success 'add --mirror=push' ' + mkdir mirror-push && + git init --bare mirror-push/public && + git init mirror-push/private && + (cd mirror-push/private && + test_commit one && + git remote add --mirror=push public ../public + ) +' + +test_expect_success 'push mirrors act as mirrors during push' ' + (cd mirror-push/private && + git branch new && + git branch -m master renamed && + git push public + ) && + (cd mirror-push/private && + git rev-parse --verify refs/heads/new && + git rev-parse --verify refs/heads/renamed && + test_must_fail git rev-parse --verify refs/heads/master + ) +' + +test_expect_success 'push mirrors do not act as mirrors during fetch' ' + (cd mirror-push/public && + git branch -m renamed renamed2 && + git symbolic-ref HEAD refs/heads/renamed2 + ) && + (cd mirror-push/private && + git fetch public && + git rev-parse --verify refs/heads/renamed && + test_must_fail git rev-parse --verify refs/heads/renamed2 + ) +' + test_expect_success 'add alt && prune' ' (mkdir alttst && cd alttst && @@ -319,6 +400,69 @@ test_expect_success 'add alt && prune' ' git rev-parse --verify refs/remotes/origin/side2) ' +cat >test/expect <<\EOF +some-tag +EOF + +test_expect_success 'add with reachable tags (default)' ' + (cd one && + >foobar && + git add foobar && + git commit -m "Foobar" && + git tag -a -m "Foobar tag" foobar-tag && + git reset --hard HEAD~1 && + git tag -a -m "Some tag" some-tag) && + (mkdir add-tags && + cd add-tags && + git init && + git remote add -f origin ../one && + git tag -l some-tag >../test/output && + git tag -l foobar-tag >>../test/output && + test_must_fail git config remote.origin.tagopt) && + test_cmp test/expect test/output +' + +cat >test/expect <<\EOF +some-tag +foobar-tag +--tags +EOF + +test_expect_success 'add --tags' ' + (rm -rf add-tags && + mkdir add-tags && + cd add-tags && + git init && + git remote add -f --tags origin ../one && + git tag -l some-tag >../test/output && + git tag -l foobar-tag >>../test/output && + git config remote.origin.tagopt >>../test/output) && + test_cmp test/expect test/output +' + +cat >test/expect <<\EOF +--no-tags +EOF + +test_expect_success 'add --no-tags' ' + (rm -rf add-tags && + mkdir add-no-tags && + cd add-no-tags && + git init && + git remote add -f --no-tags origin ../one && + git tag -l some-tag >../test/output && + git tag -l foobar-tag >../test/output && + git config remote.origin.tagopt >>../test/output) && + (cd one && + git tag -d some-tag foobar-tag) && + test_cmp test/expect test/output +' + +test_expect_success 'reject --no-no-tags' ' + (cd add-no-tags && + test_must_fail git remote add -f --no-no-tags neworigin ../one) +' + cat > one/expect << EOF apis/master apis/side @@ -371,7 +515,7 @@ test_expect_success 'update --prune' ' git branch -m side2 side3) && (cd test && git remote update --prune && - (cd ../one && git branch -m side3 side2) + (cd ../one && git branch -m side3 side2) && git rev-parse refs/remotes/origin/side3 && test_must_fail git rev-parse refs/remotes/origin/side2) ' @@ -533,44 +677,123 @@ test_expect_success 'show empty remote' ' ) ' +test_expect_success 'remote set-branches requires a remote' ' + test_must_fail git remote set-branches && + test_must_fail git remote set-branches --add +' + +test_expect_success 'remote set-branches' ' + echo "+refs/heads/*:refs/remotes/scratch/*" >expect.initial && + sort <<-\EOF >expect.add && + +refs/heads/*:refs/remotes/scratch/* + +refs/heads/other:refs/remotes/scratch/other + EOF + sort <<-\EOF >expect.replace && + +refs/heads/maint:refs/remotes/scratch/maint + +refs/heads/master:refs/remotes/scratch/master + +refs/heads/next:refs/remotes/scratch/next + EOF + sort <<-\EOF >expect.add-two && + +refs/heads/maint:refs/remotes/scratch/maint + +refs/heads/master:refs/remotes/scratch/master + +refs/heads/next:refs/remotes/scratch/next + +refs/heads/pu:refs/remotes/scratch/pu + +refs/heads/t/topic:refs/remotes/scratch/t/topic + EOF + sort <<-\EOF >expect.setup-ffonly && + refs/heads/master:refs/remotes/scratch/master + +refs/heads/next:refs/remotes/scratch/next + EOF + sort <<-\EOF >expect.respect-ffonly && + refs/heads/master:refs/remotes/scratch/master + +refs/heads/next:refs/remotes/scratch/next + +refs/heads/pu:refs/remotes/scratch/pu + EOF + + git clone .git/ setbranches && + ( + cd setbranches && + git remote rename origin scratch && + git config --get-all remote.scratch.fetch >config-result && + sort ../actual.initial && + + git remote set-branches scratch --add other && + git config --get-all remote.scratch.fetch >config-result && + sort ../actual.add && + + git remote set-branches scratch maint master next && + git config --get-all remote.scratch.fetch >config-result && + sort ../actual.replace && + + git remote set-branches --add scratch pu t/topic && + git config --get-all remote.scratch.fetch >config-result && + sort ../actual.add-two && + + git config --unset-all remote.scratch.fetch && + git config remote.scratch.fetch \ + refs/heads/master:refs/remotes/scratch/master && + git config --add remote.scratch.fetch \ + +refs/heads/next:refs/remotes/scratch/next && + git config --get-all remote.scratch.fetch >config-result && + sort ../actual.setup-ffonly && + + git remote set-branches --add scratch pu && + git config --get-all remote.scratch.fetch >config-result && + sort ../actual.respect-ffonly + ) && + test_cmp expect.initial actual.initial && + test_cmp expect.add actual.add && + test_cmp expect.replace actual.replace && + test_cmp expect.add-two actual.add-two && + test_cmp expect.setup-ffonly actual.setup-ffonly && + test_cmp expect.respect-ffonly actual.respect-ffonly +' + +test_expect_success 'remote set-branches with --mirror' ' + echo "+refs/*:refs/*" >expect.initial && + echo "+refs/heads/master:refs/heads/master" >expect.replace && + git clone --mirror .git/ setbranches-mirror && + ( + cd setbranches-mirror && + git remote rename origin scratch && + git config --get-all remote.scratch.fetch >../actual.initial && + + git remote set-branches scratch heads/master && + git config --get-all remote.scratch.fetch >../actual.replace + ) && + test_cmp expect.initial actual.initial && + test_cmp expect.replace actual.replace +' + test_expect_success 'new remote' ' -( git remote add someremote foo && echo foo >expect && git config --get-all remote.someremote.url >actual && cmp expect actual -) ' test_expect_success 'remote set-url bar' ' -( git remote set-url someremote bar && echo bar >expect && git config --get-all remote.someremote.url >actual && cmp expect actual -) ' test_expect_success 'remote set-url baz bar' ' -( git remote set-url someremote baz bar && echo baz >expect && git config --get-all remote.someremote.url >actual && cmp expect actual -) ' test_expect_success 'remote set-url zot bar' ' -( test_must_fail git remote set-url someremote zot bar && echo baz >expect && git config --get-all remote.someremote.url >actual && cmp expect actual -) ' test_expect_success 'remote set-url --push zot baz' ' -( test_must_fail git remote set-url --push someremote zot baz && echo "YYY" >expect && echo baz >>expect && @@ -578,11 +801,9 @@ test_expect_success 'remote set-url --push zot baz' ' 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 && @@ -591,11 +812,9 @@ test_expect_success 'remote set-url --push zot' ' 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 && echo "YYY" >>expect && @@ -604,11 +823,9 @@ test_expect_success 'remote set-url --push qux zot' ' echo "YYY" >>actual && git config --get-all remote.someremote.url >>actual && cmp expect actual -) ' test_expect_success 'remote set-url --push foo qu+x' ' -( git remote set-url --push someremote foo qu+x && echo foo >expect && echo "YYY" >>expect && @@ -617,11 +834,9 @@ test_expect_success 'remote set-url --push foo qu+x' ' echo "YYY" >>actual && git config --get-all remote.someremote.url >>actual && cmp expect actual -) ' test_expect_success 'remote set-url --push --add aaa' ' -( git remote set-url --push --add someremote aaa && echo foo >expect && echo aaa >>expect && @@ -631,11 +846,9 @@ test_expect_success 'remote set-url --push --add aaa' ' echo "YYY" >>actual && git config --get-all remote.someremote.url >>actual && cmp expect actual -) ' test_expect_success 'remote set-url --push bar aaa' ' -( git remote set-url --push someremote bar aaa && echo foo >expect && echo bar >>expect && @@ -645,11 +858,9 @@ test_expect_success 'remote set-url --push bar aaa' ' echo "YYY" >>actual && git config --get-all remote.someremote.url >>actual && cmp expect actual -) ' test_expect_success 'remote set-url --push --delete bar' ' -( git remote set-url --push --delete someremote bar && echo foo >expect && echo "YYY" >>expect && @@ -658,11 +869,9 @@ test_expect_success 'remote set-url --push --delete bar' ' 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 "YYY" >expect && echo baz >>expect && @@ -670,11 +879,9 @@ test_expect_success 'remote set-url --push --delete foo' ' echo "YYY" >>actual && git config --get-all remote.someremote.url >>actual && cmp expect actual -) ' test_expect_success 'remote set-url --add bbb' ' -( git remote set-url --add someremote bbb && echo "YYY" >expect && echo baz >>expect && @@ -683,12 +890,10 @@ test_expect_success 'remote set-url --add bbb' ' echo "YYY" >>actual && git config --get-all remote.someremote.url >>actual && cmp expect actual -) ' test_expect_success 'remote set-url --delete .*' ' -( - test_must_fail git remote set-url --delete someremote .* && + test_must_fail git remote set-url --delete someremote .\* && echo "YYY" >expect && echo baz >>expect && echo bbb >>expect && @@ -696,11 +901,9 @@ test_expect_success 'remote set-url --delete .*' ' echo "YYY" >>actual && git config --get-all remote.someremote.url >>actual && cmp expect actual -) ' test_expect_success 'remote set-url --delete bbb' ' -( git remote set-url --delete someremote bbb && echo "YYY" >expect && echo baz >>expect && @@ -708,11 +911,9 @@ test_expect_success 'remote set-url --delete bbb' ' echo "YYY" >>actual && git config --get-all remote.someremote.url >>actual && cmp expect actual -) ' test_expect_success 'remote set-url --delete baz' ' -( test_must_fail git remote set-url --delete someremote baz && echo "YYY" >expect && echo baz >>expect && @@ -720,11 +921,9 @@ test_expect_success 'remote set-url --delete baz' ' echo "YYY" >>actual && git config --get-all remote.someremote.url >>actual && cmp expect actual -) ' test_expect_success 'remote set-url --add ccc' ' -( git remote set-url --add someremote ccc && echo "YYY" >expect && echo baz >>expect && @@ -733,11 +932,9 @@ test_expect_success 'remote set-url --add ccc' ' echo "YYY" >>actual && git config --get-all remote.someremote.url >>actual && cmp expect actual -) ' test_expect_success 'remote set-url --delete baz' ' -( git remote set-url --delete someremote baz && echo "YYY" >expect && echo ccc >>expect && @@ -745,7 +942,6 @@ test_expect_success 'remote set-url --delete baz' ' echo "YYY" >>actual && git config --get-all remote.someremote.url >>actual && cmp expect actual -) ' test_done