Merge branch 'ps/ref-tests-update-even-more'

More tests that are marked as "ref-files only" have been updated to
improve test coverage of reftable backend.

* ps/ref-tests-update-even-more:
  t7003: ensure filter-branch prunes reflogs with the reftable backend
  t2011: exercise D/F conflicts with HEAD with the reftable backend
  t1405: remove unneeded cleanup step
  t1404: make D/F conflict tests compatible with reftable backend
  t1400: exercise reflog with gaps with reftable backend
  t0410: convert tests to use DEFAULT_REPO_FORMAT prereq
  t: move tests exercising the "files" backend
This commit is contained in:
Junio C Hamano 2024-02-26 18:10:25 -08:00
commit 7ece6ad823
10 changed files with 125 additions and 140 deletions

View file

@ -49,7 +49,7 @@ test_expect_success 'convert shallow clone to partial clone' '
test_cmp_config -C client 1 core.repositoryformatversion
'
test_expect_success SHA1,REFFILES 'convert to partial clone with noop extension' '
test_expect_success DEFAULT_REPO_FORMAT 'convert to partial clone with noop extension' '
rm -fr server client &&
test_create_repo server &&
test_commit -C server my_commit 1 &&
@ -60,7 +60,7 @@ test_expect_success SHA1,REFFILES 'convert to partial clone with noop extension'
git -C client fetch --unshallow --filter="blob:none"
'
test_expect_success SHA1,REFFILES 'converting to partial clone fails with unrecognized extension' '
test_expect_success DEFAULT_REPO_FORMAT 'converting to partial clone fails with unrecognized extension' '
rm -fr server client &&
test_create_repo server &&
test_commit -C server my_commit 1 &&

View file

@ -381,4 +381,95 @@ test_expect_success 'log diagnoses bogus HEAD symref' '
test_grep broken stderr
'
test_expect_success 'empty directory removal' '
git branch d1/d2/r1 HEAD &&
git branch d1/r2 HEAD &&
test_path_is_file .git/refs/heads/d1/d2/r1 &&
test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
git branch -d d1/d2/r1 &&
test_must_fail git show-ref --verify -q refs/heads/d1/d2 &&
test_must_fail git show-ref --verify -q logs/refs/heads/d1/d2 &&
test_path_is_file .git/refs/heads/d1/r2 &&
test_path_is_file .git/logs/refs/heads/d1/r2
'
test_expect_success 'symref empty directory removal' '
git branch e1/e2/r1 HEAD &&
git branch e1/r2 HEAD &&
git checkout e1/e2/r1 &&
test_when_finished "git checkout main" &&
test_path_is_file .git/refs/heads/e1/e2/r1 &&
test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
git update-ref -d HEAD &&
test_must_fail git show-ref --verify -q refs/heads/e1/e2 &&
test_must_fail git show-ref --verify -q logs/refs/heads/e1/e2 &&
test_path_is_file .git/refs/heads/e1/r2 &&
test_path_is_file .git/logs/refs/heads/e1/r2 &&
test_path_is_file .git/logs/HEAD
'
test_expect_success 'directory not created deleting packed ref' '
git branch d1/d2/r1 HEAD &&
git pack-refs --all &&
test_path_is_missing .git/refs/heads/d1/d2 &&
git update-ref -d refs/heads/d1/d2/r1 &&
test_path_is_missing .git/refs/heads/d1/d2 &&
test_path_is_missing .git/refs/heads/d1
'
test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
git branch --create-reflog u &&
mv .git/logs/refs/heads/u real-u &&
ln -s real-u .git/logs/refs/heads/u &&
test_must_fail git branch -m u v
'
test_expect_success SYMLINKS 'git branch -m with symlinked .git/refs' '
test_when_finished "rm -rf subdir" &&
git init --bare subdir &&
rm -rfv subdir/refs subdir/objects subdir/packed-refs &&
ln -s ../.git/refs subdir/refs &&
ln -s ../.git/objects subdir/objects &&
ln -s ../.git/packed-refs subdir/packed-refs &&
git -C subdir rev-parse --absolute-git-dir >subdir.dir &&
git rev-parse --absolute-git-dir >our.dir &&
! test_cmp subdir.dir our.dir &&
git -C subdir log &&
git -C subdir branch rename-src &&
git rev-parse rename-src >expect &&
git -C subdir branch -m rename-src rename-dest &&
git rev-parse rename-dest >actual &&
test_cmp expect actual &&
git branch -D rename-dest
'
test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '
git checkout main &&
mv .git/logs actual_logs &&
cmd //c "mklink /D .git\logs ..\actual_logs" &&
git rebase -f HEAD^ &&
test -L .git/logs &&
rm .git/logs &&
mv actual_logs .git/logs
'
test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
umask 077 &&
git config core.sharedRepository group &&
git reflog expire --all &&
actual="$(ls -l .git/logs/refs/heads/main)" &&
case "$actual" in
-rw-rw-*)
: happy
;;
*)
echo Ooops, .git/logs/refs/heads/main is not 066x [$actual]
false
;;
esac
'
test_done

View file

@ -137,22 +137,6 @@ test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '
test_cmp expect actual
'
test_expect_success REFFILES,POSIXPERM 'git reflog expire honors core.sharedRepository' '
umask 077 &&
git config core.sharedRepository group &&
git reflog expire --all &&
actual="$(ls -l .git/logs/refs/heads/main)" &&
case "$actual" in
-rw-rw-*)
: happy
;;
*)
echo Ooops, .git/logs/refs/heads/main is not 066x [$actual]
false
;;
esac
'
test_expect_success POSIXPERM 'forced modes' '
test_when_finished "rm -rf new" &&
mkdir -p templates/hooks &&

View file

@ -288,33 +288,6 @@ test_expect_success "set $m (logged by touch)" '
test $A = $(git show-ref -s --verify $m)
'
test_expect_success REFFILES 'empty directory removal' '
git branch d1/d2/r1 HEAD &&
git branch d1/r2 HEAD &&
test_path_is_file .git/refs/heads/d1/d2/r1 &&
test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
git branch -d d1/d2/r1 &&
test_must_fail git show-ref --verify -q refs/heads/d1/d2 &&
test_must_fail git show-ref --verify -q logs/refs/heads/d1/d2 &&
test_path_is_file .git/refs/heads/d1/r2 &&
test_path_is_file .git/logs/refs/heads/d1/r2
'
test_expect_success REFFILES 'symref empty directory removal' '
git branch e1/e2/r1 HEAD &&
git branch e1/r2 HEAD &&
git checkout e1/e2/r1 &&
test_when_finished "git checkout main" &&
test_path_is_file .git/refs/heads/e1/e2/r1 &&
test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
git update-ref -d HEAD &&
test_must_fail git show-ref --verify -q refs/heads/e1/e2 &&
test_must_fail git show-ref --verify -q logs/refs/heads/e1/e2 &&
test_path_is_file .git/refs/heads/e1/r2 &&
test_path_is_file .git/logs/refs/heads/e1/r2 &&
test_path_is_file .git/logs/HEAD
'
cat >expect <<EOF
$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 Initial Creation
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch
@ -453,15 +426,15 @@ test_expect_success 'Query "main@{2005-05-28}" (past end of history)' '
rm -f expect
git update-ref -d $m
test_expect_success REFFILES 'query reflog with gap' '
test_expect_success 'query reflog with gap' '
test_when_finished "git update-ref -d $m" &&
git update-ref $m $F &&
cat >.git/logs/$m <<-EOF &&
$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
$D $F $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
EOF
GIT_COMMITTER_DATE="1117150320 -0500" git update-ref $m $A &&
GIT_COMMITTER_DATE="1117150380 -0500" git update-ref $m $B &&
GIT_COMMITTER_DATE="1117150480 -0500" git update-ref $m $C &&
GIT_COMMITTER_DATE="1117150580 -0500" git update-ref $m $D &&
GIT_COMMITTER_DATE="1117150680 -0500" git update-ref $m $F &&
git reflog delete $m@{2} &&
git rev-parse --verify "main@{2005-05-26 23:33:01}" >actual 2>stderr &&
echo "$B" >expect &&
@ -1668,13 +1641,4 @@ test_expect_success PIPE 'transaction flushes status updates' '
test_cmp expected actual
'
test_expect_success REFFILES 'directory not created deleting packed ref' '
git branch d1/d2/r1 HEAD &&
git pack-refs --all &&
test_path_is_missing .git/refs/heads/d1/d2 &&
git update-ref -d refs/heads/d1/d2/r1 &&
test_path_is_missing .git/refs/heads/d1/d2 &&
test_path_is_missing .git/refs/heads/d1
'
test_done

View file

@ -92,9 +92,6 @@ df_test() {
else
delname="$delref"
fi &&
cat >expected-err <<-EOF &&
fatal: cannot lock ref $SQ$addname$SQ: $SQ$delref$SQ exists; cannot create $SQ$addref$SQ
EOF
$pack &&
if $add_del
then
@ -103,7 +100,7 @@ df_test() {
printf "%s\n" "delete $delname" "create $addname $D"
fi >commands &&
test_must_fail git update-ref --stdin <commands 2>output.err &&
test_cmp expected-err output.err &&
grep "fatal:\( cannot lock ref $SQ$addname$SQ:\)\? $SQ$delref$SQ exists; cannot create $SQ$addref$SQ" output.err &&
printf "%s\n" "$C $delref" >expected-refs &&
git for-each-ref --format="%(objectname) %(refname)" $prefix/r >actual-refs &&
test_cmp expected-refs actual-refs
@ -191,69 +188,69 @@ test_expect_success 'one new ref is a simple prefix of another' '
'
test_expect_success REFFILES 'D/F conflict prevents add long + delete short' '
test_expect_success 'D/F conflict prevents add long + delete short' '
df_test refs/df-al-ds --add-del foo/bar foo
'
test_expect_success REFFILES 'D/F conflict prevents add short + delete long' '
test_expect_success 'D/F conflict prevents add short + delete long' '
df_test refs/df-as-dl --add-del foo foo/bar
'
test_expect_success REFFILES 'D/F conflict prevents delete long + add short' '
test_expect_success 'D/F conflict prevents delete long + add short' '
df_test refs/df-dl-as --del-add foo/bar foo
'
test_expect_success REFFILES 'D/F conflict prevents delete short + add long' '
test_expect_success 'D/F conflict prevents delete short + add long' '
df_test refs/df-ds-al --del-add foo foo/bar
'
test_expect_success REFFILES 'D/F conflict prevents add long + delete short packed' '
test_expect_success 'D/F conflict prevents add long + delete short packed' '
df_test refs/df-al-dsp --pack --add-del foo/bar foo
'
test_expect_success REFFILES 'D/F conflict prevents add short + delete long packed' '
test_expect_success 'D/F conflict prevents add short + delete long packed' '
df_test refs/df-as-dlp --pack --add-del foo foo/bar
'
test_expect_success REFFILES 'D/F conflict prevents delete long packed + add short' '
test_expect_success 'D/F conflict prevents delete long packed + add short' '
df_test refs/df-dlp-as --pack --del-add foo/bar foo
'
test_expect_success REFFILES 'D/F conflict prevents delete short packed + add long' '
test_expect_success 'D/F conflict prevents delete short packed + add long' '
df_test refs/df-dsp-al --pack --del-add foo foo/bar
'
# Try some combinations involving symbolic refs...
test_expect_success REFFILES 'D/F conflict prevents indirect add long + delete short' '
test_expect_success 'D/F conflict prevents indirect add long + delete short' '
df_test refs/df-ial-ds --sym-add --add-del foo/bar foo
'
test_expect_success REFFILES 'D/F conflict prevents indirect add long + indirect delete short' '
test_expect_success 'D/F conflict prevents indirect add long + indirect delete short' '
df_test refs/df-ial-ids --sym-add --sym-del --add-del foo/bar foo
'
test_expect_success REFFILES 'D/F conflict prevents indirect add short + indirect delete long' '
test_expect_success 'D/F conflict prevents indirect add short + indirect delete long' '
df_test refs/df-ias-idl --sym-add --sym-del --add-del foo foo/bar
'
test_expect_success REFFILES 'D/F conflict prevents indirect delete long + indirect add short' '
test_expect_success 'D/F conflict prevents indirect delete long + indirect add short' '
df_test refs/df-idl-ias --sym-add --sym-del --del-add foo/bar foo
'
test_expect_success REFFILES 'D/F conflict prevents indirect add long + delete short packed' '
test_expect_success 'D/F conflict prevents indirect add long + delete short packed' '
df_test refs/df-ial-dsp --sym-add --pack --add-del foo/bar foo
'
test_expect_success REFFILES 'D/F conflict prevents indirect add long + indirect delete short packed' '
test_expect_success 'D/F conflict prevents indirect add long + indirect delete short packed' '
df_test refs/df-ial-idsp --sym-add --sym-del --pack --add-del foo/bar foo
'
test_expect_success REFFILES 'D/F conflict prevents add long + indirect delete short packed' '
test_expect_success 'D/F conflict prevents add long + indirect delete short packed' '
df_test refs/df-al-idsp --sym-del --pack --add-del foo/bar foo
'
test_expect_success REFFILES 'D/F conflict prevents indirect delete long packed + indirect add short' '
test_expect_success 'D/F conflict prevents indirect delete long packed + indirect add short' '
df_test refs/df-idlp-ias --sym-add --sym-del --pack --del-add foo/bar foo
'

View file

@ -33,12 +33,6 @@ test_expect_success 'delete_refs(FOO, refs/tags/new-tag)' '
test_must_fail git rev-parse refs/tags/new-tag --
'
# In reftable, we keep the reflogs around for deleted refs.
test_expect_success !REFFILES 'delete-reflog(FOO, refs/tags/new-tag)' '
$RUN delete-reflog FOO &&
$RUN delete-reflog refs/tags/new-tag
'
test_expect_success 'rename_refs(main, new-main)' '
git rev-parse main >expected &&
$RUN rename-ref refs/heads/main refs/heads/new-main &&

View file

@ -29,36 +29,33 @@ test_expect_success REFFILES 'checkout notices failure to lock HEAD' '
test_must_fail git checkout -b other
'
test_expect_success REFFILES 'create ref directory/file conflict scenario' '
test_expect_success 'create ref directory/file conflict scenario' '
git update-ref refs/heads/outer/inner main &&
# do not rely on symbolic-ref to get a known state,
# as it may use the same code we are testing
reset_to_df () {
echo "ref: refs/heads/outer" >.git/HEAD
git symbolic-ref HEAD refs/heads/outer
}
'
test_expect_success REFFILES 'checkout away from d/f HEAD (unpacked, to branch)' '
test_expect_success 'checkout away from d/f HEAD (unpacked, to branch)' '
reset_to_df &&
git checkout main
'
test_expect_success REFFILES 'checkout away from d/f HEAD (unpacked, to detached)' '
test_expect_success 'checkout away from d/f HEAD (unpacked, to detached)' '
reset_to_df &&
git checkout --detach main
'
test_expect_success REFFILES 'pack refs' '
test_expect_success 'pack refs' '
git pack-refs --all --prune
'
test_expect_success REFFILES 'checkout away from d/f HEAD (packed, to branch)' '
test_expect_success 'checkout away from d/f HEAD (packed, to branch)' '
reset_to_df &&
git checkout main
'
test_expect_success REFFILES 'checkout away from d/f HEAD (packed, to detached)' '
test_expect_success 'checkout away from d/f HEAD (packed, to detached)' '
reset_to_df &&
git checkout --detach main
'

View file

@ -836,35 +836,6 @@ test_expect_success 'renaming a symref is not allowed' '
test_ref_missing refs/heads/new-topic
'
test_expect_success SYMLINKS,REFFILES 'git branch -m u v should fail when the reflog for u is a symlink' '
git branch --create-reflog u &&
mv .git/logs/refs/heads/u real-u &&
ln -s real-u .git/logs/refs/heads/u &&
test_must_fail git branch -m u v
'
test_expect_success SYMLINKS,REFFILES 'git branch -m with symlinked .git/refs' '
test_when_finished "rm -rf subdir" &&
git init --bare subdir &&
rm -rfv subdir/refs subdir/objects subdir/packed-refs &&
ln -s ../.git/refs subdir/refs &&
ln -s ../.git/objects subdir/objects &&
ln -s ../.git/packed-refs subdir/packed-refs &&
git -C subdir rev-parse --absolute-git-dir >subdir.dir &&
git rev-parse --absolute-git-dir >our.dir &&
! test_cmp subdir.dir our.dir &&
git -C subdir log &&
git -C subdir branch rename-src &&
git rev-parse rename-src >expect &&
git -C subdir branch -m rename-src rename-dest &&
git rev-parse rename-dest >actual &&
test_cmp expect actual &&
git branch -D rename-dest
'
test_expect_success 'test tracking setup via --track' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&

View file

@ -424,16 +424,6 @@ test_expect_success 'refuse to switch to branch checked out elsewhere' '
test_grep "already used by worktree at" err
'
test_expect_success REFFILES,MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '
git checkout main &&
mv .git/logs actual_logs &&
cmd //c "mklink /D .git\logs ..\actual_logs" &&
git rebase -f HEAD^ &&
test -L .git/logs &&
rm .git/logs &&
mv actual_logs .git/logs
'
test_expect_success 'rebase when inside worktree subdirectory' '
git init main-wt &&
(

View file

@ -396,10 +396,7 @@ test_expect_success '--prune-empty is able to prune entire branch' '
git branch prune-entire B &&
git filter-branch -f --prune-empty --index-filter "git update-index --remove A.t B.t" prune-entire &&
test_must_fail git rev-parse refs/heads/prune-entire &&
if test_have_prereq REFFILES
then
test_must_fail git reflog exists refs/heads/prune-entire
fi
test_must_fail git reflog exists refs/heads/prune-entire
'
test_expect_success '--remap-to-ancestor with filename filters' '