Skip to content

Commit a21a929

Browse files
committed
Merge branch 'ps/ref-tests-update-more'
Tests update. * ps/ref-tests-update-more: t6301: write invalid object ID via `test-tool ref-store` t5551: stop writing packed-refs directly t5401: speed up creation of many branches t4013: simplify magic parsing and drop "failure" t3310: stop checking for reference existence via `test -f` t1417: make `reflog --updateref` tests backend agnostic t1410: use test-tool to create empty reflog t1401: stop treating FETCH_HEAD as real reference t1400: split up generic reflog tests from the reffile-specific ones t0410: mark tests to require the reffiles backend
2 parents 145336e + 866a1b9 commit a21a929

10 files changed

+74
-45
lines changed

t/t0410-partial-clone.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test_expect_success 'convert shallow clone to partial clone' '
4949
test_cmp_config -C client 1 core.repositoryformatversion
5050
'
5151

52-
test_expect_success SHA1 'convert to partial clone with noop extension' '
52+
test_expect_success SHA1,REFFILES 'convert to partial clone with noop extension' '
5353
rm -fr server client &&
5454
test_create_repo server &&
5555
test_commit -C server my_commit 1 &&
@@ -60,7 +60,7 @@ test_expect_success SHA1 'convert to partial clone with noop extension' '
6060
git -C client fetch --unshallow --filter="blob:none"
6161
'
6262

63-
test_expect_success SHA1 'converting to partial clone fails with unrecognized extension' '
63+
test_expect_success SHA1,REFFILES 'converting to partial clone fails with unrecognized extension' '
6464
rm -fr server client &&
6565
test_create_repo server &&
6666
test_commit -C server my_commit 1 &&

t/t1400-update-ref.sh

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,28 @@ test_expect_success "verifying $m's log (logged by config)" '
357357
'
358358

359359
test_expect_success 'set up for querying the reflog' '
360+
git update-ref -d $m &&
361+
test-tool ref-store main delete-reflog $m &&
362+
363+
GIT_COMMITTER_DATE="1117150320 -0500" git update-ref $m $C &&
364+
GIT_COMMITTER_DATE="1117150350 -0500" git update-ref $m $A &&
365+
GIT_COMMITTER_DATE="1117150380 -0500" git update-ref $m $B &&
366+
GIT_COMMITTER_DATE="1117150680 -0500" git update-ref $m $F &&
367+
GIT_COMMITTER_DATE="1117150980 -0500" git update-ref $m $E &&
360368
git update-ref $m $D &&
361-
cat >.git/logs/$m <<-EOF
369+
# Delete the last reflog entry so that the tip of m and the reflog for
370+
# it disagree.
371+
git reflog delete $m@{0} &&
372+
373+
cat >expect <<-EOF &&
362374
$Z $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
363375
$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500
364376
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
365-
$F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
366-
$Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500
377+
$B $F $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
378+
$F $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500
367379
EOF
380+
test-tool ref-store main for-each-reflog-ent $m >actual &&
381+
test_cmp expect actual
368382
'
369383

370384
ed="Thu, 26 May 2005 18:32:00 -0500"
@@ -412,13 +426,12 @@ test_expect_success 'Query "main@{2005-05-26 23:33:01}" (middle of history with
412426
test_when_finished "rm -f o e" &&
413427
git rev-parse --verify "main@{2005-05-26 23:33:01}" >o 2>e &&
414428
echo "$B" >expect &&
415-
test_cmp expect o &&
416-
test_grep -F "warning: log for ref $m has gap after $gd" e
429+
test_cmp expect o
417430
'
418431
test_expect_success 'Query "main@{2005-05-26 23:38:00}" (middle of history)' '
419432
test_when_finished "rm -f o e" &&
420433
git rev-parse --verify "main@{2005-05-26 23:38:00}" >o 2>e &&
421-
echo "$Z" >expect &&
434+
echo "$F" >expect &&
422435
test_cmp expect o &&
423436
test_must_be_empty e
424437
'
@@ -440,6 +453,22 @@ test_expect_success 'Query "main@{2005-05-28}" (past end of history)' '
440453
rm -f expect
441454
git update-ref -d $m
442455

456+
test_expect_success REFFILES 'query reflog with gap' '
457+
test_when_finished "git update-ref -d $m" &&
458+
459+
git update-ref $m $F &&
460+
cat >.git/logs/$m <<-EOF &&
461+
$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
462+
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
463+
$D $F $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
464+
EOF
465+
466+
git rev-parse --verify "main@{2005-05-26 23:33:01}" >actual 2>stderr &&
467+
echo "$B" >expect &&
468+
test_cmp expect actual &&
469+
test_grep -F "warning: log for ref $m has gap after $gd" stderr
470+
'
471+
443472
test_expect_success 'creating initial files' '
444473
test_when_finished rm -f M &&
445474
echo TEST >F &&

t/t1401-symbolic-ref.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ test_expect_success 'symbolic-ref refuses invalid target for non-HEAD' '
171171
'
172172

173173
test_expect_success 'symbolic-ref allows top-level target for non-HEAD' '
174-
git symbolic-ref refs/heads/top-level FETCH_HEAD &&
175-
git update-ref FETCH_HEAD HEAD &&
174+
git symbolic-ref refs/heads/top-level ORIG_HEAD &&
175+
git update-ref ORIG_HEAD HEAD &&
176176
test_cmp_rev top-level HEAD
177177
'
178178

t/t1410-reflog.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,11 @@ test_expect_success 'expire one of multiple worktrees' '
469469
)
470470
'
471471

472-
test_expect_success REFFILES 'empty reflog' '
472+
test_expect_success 'empty reflog' '
473473
test_when_finished "rm -rf empty" &&
474474
git init empty &&
475475
test_commit -C empty A &&
476-
>empty/.git/logs/refs/heads/foo &&
476+
test-tool ref-store main create-reflog refs/heads/foo &&
477477
git -C empty reflog expire --all 2>err &&
478478
test_must_be_empty err
479479
'

t/t1417-reflog-updateref.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ test_expect_success 'setup' '
1414
test_commit B &&
1515
test_commit C &&
1616
17-
cp .git/logs/HEAD HEAD.old &&
17+
git reflog HEAD >expect &&
1818
git reset --hard HEAD~ &&
19-
cp HEAD.old .git/logs/HEAD
19+
# Make sure that the reflog does not point to the same commit
20+
# as HEAD.
21+
git reflog delete HEAD@{0} &&
22+
git reflog HEAD >actual &&
23+
test_cmp expect actual
2024
)
2125
'
2226

@@ -25,7 +29,7 @@ test_reflog_updateref () {
2529
shift
2630
args="$@"
2731

28-
test_expect_success REFFILES "get '$exp' with '$args'" '
32+
test_expect_success "get '$exp' with '$args'" '
2933
test_when_finished "rm -rf copy" &&
3034
cp -R repo copy &&
3135

t/t3310-notes-merge-manual-resolve.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,9 @@ y and z notes on 4th commit
561561
EOF
562562
# Fail to finalize merge
563563
test_must_fail git notes merge --commit >output 2>&1 &&
564-
# .git/NOTES_MERGE_* must remain
565-
test -f .git/NOTES_MERGE_PARTIAL &&
566-
test -f .git/NOTES_MERGE_REF &&
564+
# NOTES_MERGE_* refs and .git/NOTES_MERGE_* state files must remain
565+
git rev-parse --verify NOTES_MERGE_PARTIAL &&
566+
git rev-parse --verify NOTES_MERGE_REF &&
567567
test -f .git/NOTES_MERGE_WORKTREE/$commit_sha1 &&
568568
test -f .git/NOTES_MERGE_WORKTREE/$commit_sha2 &&
569569
test -f .git/NOTES_MERGE_WORKTREE/$commit_sha3 &&

t/t4013-diff-various.sh

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,32 +178,29 @@ process_diffs () {
178178
V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g')
179179
while read magic cmd
180180
do
181-
status=success
182181
case "$magic" in
183182
'' | '#'*)
184183
continue ;;
185-
:*)
186-
magic=${magic#:}
184+
:noellipses)
185+
magic=noellipses
187186
label="$magic-$cmd"
188-
case "$magic" in
189-
noellipses) ;;
190-
failure)
191-
status=failure
192-
magic=
193-
label="$cmd" ;;
194-
*)
195-
BUG "unknown magic $magic" ;;
196-
esac ;;
187+
;;
188+
:*)
189+
BUG "unknown magic $magic"
190+
;;
197191
*)
198-
cmd="$magic $cmd" magic=
199-
label="$cmd" ;;
192+
cmd="$magic $cmd"
193+
magic=
194+
label="$cmd"
195+
;;
200196
esac
197+
201198
test=$(echo "$label" | sed -e 's|[/ ][/ ]*|_|g')
202199
pfx=$(printf "%04d" $test_count)
203200
expect="$TEST_DIRECTORY/t4013/diff.$test"
204201
actual="$pfx-diff.$test"
205202

206-
test_expect_$status "git $cmd # magic is ${magic:-(not used)}" '
203+
test_expect_success "git $cmd # magic is ${magic:-(not used)}" '
207204
{
208205
echo "$ git $cmd"
209206
case "$magic" in

t/t5401-update-hooks.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,8 @@ test_expect_success 'pre-receive hook that forgets to read its input' '
133133
EOF
134134
rm -f victim.git/hooks/update victim.git/hooks/post-update &&
135135
136-
for v in $(test_seq 100 999)
137-
do
138-
git branch branch_$v main || return
139-
done &&
136+
printf "create refs/heads/branch_%d main\n" $(test_seq 100 999) >input &&
137+
git update-ref --stdin <input &&
140138
git push ./victim.git "+refs/heads/*:refs/heads/*"
141139
'
142140

t/t5551-http-fetch-smart.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ create_tags () {
359359

360360
# now assign tags to all the dangling commits we created above
361361
tag=$(perl -e "print \"bla\" x 30") &&
362-
sed -e "s|^:\([^ ]*\) \(.*\)$|\2 refs/tags/$tag-\1|" <marks >>packed-refs
362+
sed -e "s|^:\([^ ]*\) \(.*\)$|create refs/tags/$tag-\1 \2|" <marks >input &&
363+
git update-ref --stdin <input &&
364+
rm input
363365
}
364366

365367
test_expect_success 'create 2,000 tags in the repo' '

t/t6301-for-each-ref-errors.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test_expect_success setup '
1515
git for-each-ref --format="%(objectname) %(refname)" >brief-list
1616
'
1717

18-
test_expect_success 'Broken refs are reported correctly' '
18+
test_expect_success REFFILES 'Broken refs are reported correctly' '
1919
r=refs/heads/bogus &&
2020
: >.git/$r &&
2121
test_when_finished "rm -f .git/$r" &&
@@ -25,7 +25,7 @@ test_expect_success 'Broken refs are reported correctly' '
2525
test_cmp broken-err err
2626
'
2727

28-
test_expect_success 'NULL_SHA1 refs are reported correctly' '
28+
test_expect_success REFFILES 'NULL_SHA1 refs are reported correctly' '
2929
r=refs/heads/zeros &&
3030
echo $ZEROS >.git/$r &&
3131
test_when_finished "rm -f .git/$r" &&
@@ -39,15 +39,14 @@ test_expect_success 'NULL_SHA1 refs are reported correctly' '
3939
'
4040

4141
test_expect_success 'Missing objects are reported correctly' '
42-
r=refs/heads/missing &&
43-
echo $MISSING >.git/$r &&
44-
test_when_finished "rm -f .git/$r" &&
45-
echo "fatal: missing object $MISSING for $r" >missing-err &&
42+
test_when_finished "git update-ref -d refs/heads/missing" &&
43+
test-tool ref-store main update-ref msg refs/heads/missing "$MISSING" "$ZERO_OID" REF_SKIP_OID_VERIFICATION &&
44+
echo "fatal: missing object $MISSING for refs/heads/missing" >missing-err &&
4645
test_must_fail git for-each-ref 2>err &&
4746
test_cmp missing-err err &&
4847
(
4948
cat brief-list &&
50-
echo "$MISSING $r"
49+
echo "$MISSING refs/heads/missing"
5150
) | sort -k 2 >missing-brief-expected &&
5251
git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err &&
5352
test_cmp missing-brief-expected brief-out &&

0 commit comments

Comments
 (0)