Merge branch 'pw/show-ref-pseudorefs'
"git show-ref --verify" did not show things like "CHERRY_PICK_HEAD", which has been corrected. * pw/show-ref-pseudorefs: t1400: use show-ref to check pseudorefs show-ref --verify: accept pseudorefs
This commit is contained in:
@ -172,7 +172,7 @@ static int cmd_show_ref__verify(const struct show_one_options *show_one_opts,
|
|||||||
while (*refs) {
|
while (*refs) {
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
|
|
||||||
if ((starts_with(*refs, "refs/") || !strcmp(*refs, "HEAD")) &&
|
if ((starts_with(*refs, "refs/") || refname_is_safe(*refs)) &&
|
||||||
!read_ref(*refs, &oid)) {
|
!read_ref(*refs, &oid)) {
|
||||||
show_one(show_one_opts, *refs, &oid);
|
show_one(show_one_opts, *refs, &oid);
|
||||||
}
|
}
|
||||||
|
@ -524,51 +524,51 @@ test_expect_success 'given old value for missing pseudoref, do not create' '
|
|||||||
|
|
||||||
test_expect_success 'create pseudoref' '
|
test_expect_success 'create pseudoref' '
|
||||||
git update-ref PSEUDOREF $A &&
|
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' '
|
test_expect_success 'overwrite pseudoref with no old value given' '
|
||||||
git update-ref PSEUDOREF $B &&
|
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' '
|
test_expect_success 'overwrite pseudoref with correct old value' '
|
||||||
git update-ref PSEUDOREF $C $B &&
|
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_expect_success 'do not overwrite pseudoref with wrong old value' '
|
||||||
test_must_fail git update-ref PSEUDOREF $D $E 2>err &&
|
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_grep "cannot lock ref.*expected" err
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'delete pseudoref' '
|
test_expect_success 'delete pseudoref' '
|
||||||
git update-ref -d 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' '
|
test_expect_success 'do not delete pseudoref with wrong old value' '
|
||||||
git update-ref PSEUDOREF $A &&
|
git update-ref PSEUDOREF $A &&
|
||||||
test_must_fail git update-ref -d PSEUDOREF $B 2>err &&
|
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_grep "cannot lock ref.*expected" err
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'delete pseudoref with correct old value' '
|
test_expect_success 'delete pseudoref with correct old value' '
|
||||||
git update-ref -d PSEUDOREF $A &&
|
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' '
|
test_expect_success 'create pseudoref with old OID zero' '
|
||||||
git update-ref PSEUDOREF $A $Z &&
|
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_expect_success 'do not overwrite pseudoref with old OID zero' '
|
||||||
test_when_finished git update-ref -d PSEUDOREF &&
|
test_when_finished git update-ref -d PSEUDOREF &&
|
||||||
test_must_fail git update-ref PSEUDOREF $B $Z 2>err &&
|
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
|
test_grep "already exists" err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -174,6 +174,14 @@ test_expect_success 'show-ref --verify HEAD' '
|
|||||||
test_must_be_empty actual
|
test_must_be_empty actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'show-ref --verify pseudorefs' '
|
||||||
|
git update-ref CHERRY_PICK_HEAD HEAD $ZERO_OID &&
|
||||||
|
test_when_finished "git update-ref -d CHERRY_PICK_HEAD" &&
|
||||||
|
git show-ref -s --verify HEAD >actual &&
|
||||||
|
git show-ref -s --verify CHERRY_PICK_HEAD >expect &&
|
||||||
|
test_cmp actual expect
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'show-ref --verify with dangling ref' '
|
test_expect_success 'show-ref --verify with dangling ref' '
|
||||||
sha1_file() {
|
sha1_file() {
|
||||||
echo "$*" | sed "s#..#.git/objects/&/#"
|
echo "$*" | sed "s#..#.git/objects/&/#"
|
||||||
|
Reference in New Issue
Block a user