diff options
Diffstat (limited to 't/t1503-rev-parse-verify.sh')
-rwxr-xr-x | t/t1503-rev-parse-verify.sh | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh index 492edffa9c..bf08102391 100755 --- a/t/t1503-rev-parse-verify.sh +++ b/t/t1503-rev-parse-verify.sh @@ -6,6 +6,9 @@ test_description='test git rev-parse --verify' exec </dev/null +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh add_line_into_file() @@ -51,8 +54,8 @@ test_expect_success 'works with one good rev' ' test "$rev_hash3" = "$HASH3" && rev_hash4=$(git rev-parse --verify $HASH4) && test "$rev_hash4" = "$HASH4" && - rev_master=$(git rev-parse --verify master) && - test "$rev_master" = "$HASH4" && + rev_main=$(git rev-parse --verify main) && + test "$rev_main" = "$HASH4" && rev_head=$(git rev-parse --verify HEAD) && test "$rev_head" = "$HASH4" ' @@ -86,8 +89,8 @@ test_expect_success 'fails silently when using -q' ' test_expect_success 'fails silently when using -q with deleted reflogs' ' ref=$(git rev-parse HEAD) && git update-ref --create-reflog -m "message for refs/test" refs/test "$ref" && - git reflog delete --updateref --rewrite refs/test@{0} && - test_must_fail git rev-parse -q --verify refs/test@{0} >error 2>&1 && + git reflog delete --updateref --rewrite refs/test@{1} && + test_must_fail git rev-parse -q --verify refs/test@{1} >error 2>&1 && test_must_be_empty error ' @@ -116,27 +119,27 @@ test_expect_success 'no stdout output on error' ' ' test_expect_success 'use --default' ' - git rev-parse --verify --default master && - git rev-parse --verify --default master HEAD && - git rev-parse --default master --verify && - git rev-parse --default master --verify HEAD && - git rev-parse --verify HEAD --default master && - test_must_fail git rev-parse --verify foo --default master && + git rev-parse --verify --default main && + git rev-parse --verify --default main HEAD && + git rev-parse --default main --verify && + git rev-parse --default main --verify HEAD && + git rev-parse --verify HEAD --default main && + test_must_fail git rev-parse --verify foo --default main && test_must_fail git rev-parse --default HEAD --verify bar && test_must_fail git rev-parse --verify --default HEAD baz && test_must_fail git rev-parse --default foo --verify && test_must_fail git rev-parse --verify --default bar ' -test_expect_success 'master@{n} for various n' ' +test_expect_success 'main@{n} for various n' ' N=$(git reflog | wc -l) && Nm1=$(($N-1)) && Np1=$(($N+1)) && - git rev-parse --verify master@{0} && - git rev-parse --verify master@{1} && - git rev-parse --verify master@{$Nm1} && - test_must_fail git rev-parse --verify master@{$N} && - test_must_fail git rev-parse --verify master@{$Np1} + git rev-parse --verify main@{0} && + git rev-parse --verify main@{1} && + git rev-parse --verify main@{$Nm1} && + test_must_fail git rev-parse --verify main@{$N} && + test_must_fail git rev-parse --verify main@{$Np1} ' test_expect_success SYMLINKS 'ref resolution not confused by broken symlinks' ' @@ -144,4 +147,17 @@ test_expect_success SYMLINKS 'ref resolution not confused by broken symlinks' ' test_must_fail git rev-parse --verify broken ' +test_expect_success 'options can appear after --verify' ' + git rev-parse --verify HEAD >expect && + git rev-parse --verify -q HEAD >actual && + test_cmp expect actual +' + +test_expect_success 'verify respects --end-of-options' ' + git update-ref refs/heads/-tricky HEAD && + git rev-parse --verify HEAD >expect && + git rev-parse --verify --end-of-options -tricky >actual && + test_cmp expect actual +' + test_done |