Add some basic tests for git push --mirror mode. Signed-off-by: Andy Whitcroft <apw@xxxxxxxxxxxx> --- t/t5517-push-mirror.sh | 101 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 101 insertions(+), 0 deletions(-) diff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh new file mode 100755 index 0000000..1a285d4 --- /dev/null +++ b/t/t5517-push-mirror.sh @@ -0,0 +1,101 @@ +#!/bin/sh + +test_description='pushing to a mirror repository' + +. ./test-lib.sh + +D=`pwd` + +mk_repo_pair () { + rm -rf master mirror && + mkdir mirror && cd mirror && + git init && + cd .. && + mkdir master && cd master && + git init && + git config remote.up.url ../mirror && + cd .. +} + +test_expect_success 'push mirror does not create new branches' ' + + mk_repo_pair && + cd master && + echo one >foo && git add foo && git commit -m one && + master_master=$(git show-ref -s --verify refs/heads/master) && + git push --mirror up && + cd ../mirror && + mirror_master=$(git show-ref -s --verify refs/heads/master) && + test "$master_master" = "$mirror_master" + +' + +test_expect_success 'push mirror does not update existing branches' ' + + mk_repo_pair && + cd master && + echo one >foo && git add foo && git commit -m one && + git push --mirror up && + echo two >foo && git add foo && git commit -m two && + master_master=$(git show-ref -s --verify refs/heads/master) && + git push --mirror up && + cd ../mirror && + mirror_master=$(git show-ref -s --verify refs/heads/master) && + test "$master_master" = "$mirror_master" + +' + +test_expect_success 'push mirror does not force update existing branches' ' + + mk_repo_pair && + cd master && + echo one >foo && git add foo && git commit -m one && + git push --mirror up && + echo two >foo && git add foo && git commit -m two && + git push --mirror up && + git reset --hard HEAD^ + master_master=$(git show-ref -s --verify refs/heads/master) && + git push --mirror up && + cd ../mirror && + mirror_master=$(git show-ref -s --verify refs/heads/master) && + test "$master_master" = "$mirror_master" + +' + +test_expect_failure 'push mirror does not remove branches' ' + + mk_repo_pair && + cd master && + echo one >foo && git add foo && git commit -m one && + git branch remove master && + git push --mirror up && + git branch -D remove + git push --mirror up && + cd ../mirror && + git show-ref -s --verify refs/heads/remove + +' + +test_expect_success 'push mirror does not add, update and remove together' ' + + mk_repo_pair && + cd master && + echo one >foo && git add foo && git commit -m one && + git branch remove master && + git push --mirror up && + git branch -D remove && + git branch add master && + echo two >foo && git add foo && git commit -m two && + master_master=$(git show-ref -s --verify refs/heads/master) && + master_add=$(git show-ref -s --verify refs/heads/add) && + git push --mirror up && + cd ../mirror && + mirror_master=$(git show-ref -s --verify refs/heads/master) && + mirror_add=$(git show-ref -s --verify refs/heads/add) && + test "$master_master" = "$mirror_master" && + test "$master_add" = "$mirror_add" && + ! git show-ref -s --verify refs/heads/remove + +' + +test_done - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html