Git fork
at reftables-rust 65 lines 1.6 kB view raw
1#!/bin/sh 2 3test_description='tracking branch update checks for git push' 4 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 7 8. ./test-lib.sh 9 10test_expect_success 'setup' ' 11 echo 1 >file && 12 git add file && 13 git commit -m 1 && 14 git branch b1 && 15 git branch b2 && 16 git branch b3 && 17 git clone . aa && 18 git checkout b1 && 19 echo b1 >>file && 20 git commit -a -m b1 && 21 git checkout b2 && 22 echo b2 >>file && 23 git commit -a -m b2 24' 25 26test_expect_success 'prepare pushable branches' ' 27 cd aa && 28 b1=$(git rev-parse origin/b1) && 29 b2=$(git rev-parse origin/b2) && 30 git checkout -b b1 origin/b1 && 31 echo aa-b1 >>file && 32 git commit -a -m aa-b1 && 33 git checkout -b b2 origin/b2 && 34 echo aa-b2 >>file && 35 git commit -a -m aa-b2 && 36 git checkout main && 37 echo aa-main >>file && 38 git commit -a -m aa-main 39' 40 41test_expect_success 'mixed-success push returns error' ' 42 test_must_fail git push origin : 43' 44 45test_expect_success 'check tracking branches updated correctly after push' ' 46 test "$(git rev-parse origin/main)" = "$(git rev-parse main)" 47' 48 49test_expect_success 'check tracking branches not updated for failed refs' ' 50 test "$(git rev-parse origin/b1)" = "$b1" && 51 test "$(git rev-parse origin/b2)" = "$b2" 52' 53 54test_expect_success 'deleted branches have their tracking branches removed' ' 55 git push origin :b1 && 56 test "$(git rev-parse origin/b1)" = "origin/b1" 57' 58 59test_expect_success 'already deleted tracking branches ignored' ' 60 git branch -d -r origin/b3 && 61 git push origin :b3 >output 2>&1 && 62 ! grep "^error: " output 63' 64 65test_done