mirror of
https://github.com/git/git
synced 2024-10-30 13:20:15 +00:00
31f898397b
The ref and reflog iterators share much of the same underlying code to iterate over the corresponding entries. This results in some weird code because the reflog iterator also exposes an object ID as well as a flag to the callback function. Neither of these fields do refer to the reflog though -- they refer to the corresponding ref with the same name. This is quite misleading. In practice at least the object ID cannot really be implemented in any other way as a reflog does not have a specific object ID in the first place. This is further stressed by the fact that none of the callbacks except for our test helper make use of these fields. Split up the infrastucture so that ref and reflog iterators use separate callback signatures. This allows us to drop the nonsensical fields from the reflog iterator. Note that internally, the backends still use the same shared infra to iterate over both types. As the backends should never end up being called directly anyway, this is not much of a problem and thus kept as-is for simplicity's sake. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
99 lines
2.2 KiB
Bash
Executable file
99 lines
2.2 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='test submodule ref store api'
|
|
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
RUN="test-tool ref-store submodule:sub"
|
|
|
|
test_expect_success 'setup' '
|
|
git init sub &&
|
|
(
|
|
cd sub &&
|
|
test_commit first &&
|
|
git checkout -b new-main &&
|
|
git tag -a -m new-tag new-tag HEAD
|
|
)
|
|
'
|
|
|
|
test_expect_success 'pack_refs() not allowed' '
|
|
test_must_fail $RUN pack-refs 3
|
|
'
|
|
|
|
test_expect_success 'create_symref() not allowed' '
|
|
test_must_fail $RUN create-symref FOO refs/heads/main nothing
|
|
'
|
|
|
|
test_expect_success 'delete_refs() not allowed' '
|
|
test_must_fail $RUN delete-refs 0 nothing FOO refs/tags/new-tag
|
|
'
|
|
|
|
test_expect_success 'rename_refs() not allowed' '
|
|
test_must_fail $RUN rename-ref refs/heads/main refs/heads/new-main
|
|
'
|
|
|
|
test_expect_success 'for_each_ref(refs/heads/)' '
|
|
$RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
|
|
cat >expected <<-\EOF &&
|
|
main 0x0
|
|
new-main 0x0
|
|
EOF
|
|
test_cmp expected actual
|
|
'
|
|
|
|
test_expect_success 'for_each_ref() is sorted' '
|
|
$RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
|
|
sort actual > expected &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
test_expect_success 'resolve_ref(main)' '
|
|
SHA1=`git -C sub rev-parse main` &&
|
|
echo "$SHA1 refs/heads/main 0x0" >expected &&
|
|
$RUN resolve-ref refs/heads/main 0 >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
test_expect_success 'verify_ref(new-main)' '
|
|
$RUN verify-ref refs/heads/new-main
|
|
'
|
|
|
|
test_expect_success 'for_each_reflog()' '
|
|
$RUN for-each-reflog >actual &&
|
|
cat >expected <<-\EOF &&
|
|
HEAD
|
|
refs/heads/main
|
|
refs/heads/new-main
|
|
EOF
|
|
test_cmp expected actual
|
|
'
|
|
|
|
test_expect_success 'for_each_reflog_ent()' '
|
|
$RUN for-each-reflog-ent HEAD >actual &&
|
|
head -n1 actual | grep first &&
|
|
tail -n1 actual | grep main.to.new
|
|
'
|
|
|
|
test_expect_success 'for_each_reflog_ent_reverse()' '
|
|
$RUN for-each-reflog-ent-reverse HEAD >actual &&
|
|
head -n1 actual | grep main.to.new &&
|
|
tail -n1 actual | grep first
|
|
'
|
|
|
|
test_expect_success 'reflog_exists(HEAD)' '
|
|
$RUN reflog-exists HEAD
|
|
'
|
|
|
|
test_expect_success 'delete_reflog() not allowed' '
|
|
test_must_fail $RUN delete-reflog HEAD
|
|
'
|
|
|
|
test_expect_success 'create-reflog() not allowed' '
|
|
test_must_fail $RUN create-reflog HEAD
|
|
'
|
|
|
|
test_done
|