Files
git/t/lib-midx.sh
Taylor Blau acfdb54eb3 t5334: expose shared nth_line() helper
Since commit 0cd2255e64 (midx: support custom `--base` for incremental
MIDX writes, 2026-05-19), t5334 has referred to a non-existent helper
function 'nth_line', which is defined in t5335, but not here.

Move the helper to lib-midx.sh so that both tests can use the same
implementation. Ensure likewise that `nth_line()` remains visible from
within t5335 by sourcing lib-midx.sh there appropriately.

Curiously, t5334 passes both before and after this change. Before this
change, the failed command substitution leaves '--base' with an empty
value, and after this change, the custom base value is still ignored by
the normal incremental write path. The following commits will explain
and address that behavior.

Noticed-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-06-12 13:39:36 -07:00

43 lines
1.0 KiB
Bash

# test_midx_consistent <objdir>
test_midx_consistent () {
ls $1/pack/pack-*.idx | xargs -n 1 basename | sort >expect &&
test-tool read-midx $1 | grep ^pack-.*\.idx$ | sort >actual &&
test_cmp expect actual &&
git multi-pack-index --object-dir=$1 verify
}
midx_checksum () {
test-tool read-midx --checksum "$1"
}
midx_git_two_modes () {
git -c core.multiPackIndex=false $1 >expect &&
git -c core.multiPackIndex=true $1 >actual &&
if [ "$2" = "sorted" ]
then
sort <expect >expect.sorted &&
mv expect.sorted expect &&
sort <actual >actual.sorted &&
mv actual.sorted actual
fi &&
test_cmp expect actual
}
compare_results_with_midx () {
MSG=$1
test_expect_success "check normal git operations: $MSG" '
midx_git_two_modes "rev-list --objects --all" &&
midx_git_two_modes "log --raw" &&
midx_git_two_modes "count-objects --verbose" &&
midx_git_two_modes "cat-file --batch-all-objects --batch-check" &&
midx_git_two_modes "cat-file --batch-all-objects --batch-check --unordered" sorted
'
}
nth_line() {
local n="$1"
shift
awk "NR==$n" "$@"
}