From acfdb54eb359c9912fb74ec260f00d73e0b2d785 Mon Sep 17 00:00:00 2001 From: Taylor Blau Date: Fri, 12 Jun 2026 16:07:08 -0400 Subject: [PATCH] t5334: expose shared `nth_line()` helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit 0cd2255e64b (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 Signed-off-by: Taylor Blau Signed-off-by: Junio C Hamano --- t/lib-midx.sh | 6 ++++++ t/t5335-compact-multi-pack-index.sh | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/t/lib-midx.sh b/t/lib-midx.sh index e38c609604..b522dbdb0f 100644 --- a/t/lib-midx.sh +++ b/t/lib-midx.sh @@ -34,3 +34,9 @@ compare_results_with_midx () { midx_git_two_modes "cat-file --batch-all-objects --batch-check --unordered" sorted ' } + +nth_line() { + local n="$1" + shift + awk "NR==$n" "$@" +} diff --git a/t/t5335-compact-multi-pack-index.sh b/t/t5335-compact-multi-pack-index.sh index ec1dafe89f..6a4b799b9c 100755 --- a/t/t5335-compact-multi-pack-index.sh +++ b/t/t5335-compact-multi-pack-index.sh @@ -3,6 +3,7 @@ test_description='multi-pack-index compaction' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-midx.sh GIT_TEST_MULTI_PACK_INDEX=0 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 @@ -13,12 +14,6 @@ packdir=$objdir/pack midxdir=$packdir/multi-pack-index.d midx_chain=$midxdir/multi-pack-index-chain -nth_line() { - local n="$1" - shift - awk "NR==$n" "$@" -} - write_packs () { for c in "$@" do