Skip to content

Commit

Permalink
t1400: use show-ref to check pseudorefs
Browse files Browse the repository at this point in the history
Now that "git show-ref --verify" accepts pseudorefs use that in
preference to "git rev-parse" when checking pseudorefs as we do when
checking branches etc.

Signed-off-by: Phillip Wood <[email protected]>
  • Loading branch information
phillipwood committed Feb 6, 2024
1 parent 4dedc57 commit b828456
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions t/t1400-update-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -524,51 +524,51 @@ test_expect_success 'given old value for missing pseudoref, do not create' '

test_expect_success 'create pseudoref' '
git update-ref PSEUDOREF $A &&
test $A = $(git rev-parse PSEUDOREF)
test $A = $(git show-ref -s --verify PSEUDOREF)
'

test_expect_success 'overwrite pseudoref with no old value given' '
git update-ref PSEUDOREF $B &&
test $B = $(git rev-parse PSEUDOREF)
test $B = $(git show-ref -s --verify PSEUDOREF)
'

test_expect_success 'overwrite pseudoref with correct old value' '
git update-ref PSEUDOREF $C $B &&
test $C = $(git rev-parse PSEUDOREF)
test $C = $(git show-ref -s --verify PSEUDOREF)
'

test_expect_success 'do not overwrite pseudoref with wrong old value' '
test_must_fail git update-ref PSEUDOREF $D $E 2>err &&
test $C = $(git rev-parse PSEUDOREF) &&
test $C = $(git show-ref -s --verify PSEUDOREF) &&
test_grep "cannot lock ref.*expected" err
'

test_expect_success 'delete pseudoref' '
git update-ref -d PSEUDOREF &&
test_must_fail git rev-parse PSEUDOREF
test_must_fail git show-ref -s --verify PSEUDOREF
'

test_expect_success 'do not delete pseudoref with wrong old value' '
git update-ref PSEUDOREF $A &&
test_must_fail git update-ref -d PSEUDOREF $B 2>err &&
test $A = $(git rev-parse PSEUDOREF) &&
test $A = $(git show-ref -s --verify PSEUDOREF) &&
test_grep "cannot lock ref.*expected" err
'

test_expect_success 'delete pseudoref with correct old value' '
git update-ref -d PSEUDOREF $A &&
test_must_fail git rev-parse PSEUDOREF
test_must_fail git show-ref -s --verify PSEUDOREF
'

test_expect_success 'create pseudoref with old OID zero' '
git update-ref PSEUDOREF $A $Z &&
test $A = $(git rev-parse PSEUDOREF)
test $A = $(git show-ref -s --verify PSEUDOREF)
'

test_expect_success 'do not overwrite pseudoref with old OID zero' '
test_when_finished git update-ref -d PSEUDOREF &&
test_must_fail git update-ref PSEUDOREF $B $Z 2>err &&
test $A = $(git rev-parse PSEUDOREF) &&
test $A = $(git show-ref -s --verify PSEUDOREF) &&
test_grep "already exists" err
'

Expand Down

0 comments on commit b828456

Please sign in to comment.