]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t5334: expose shared `nth_line()` helper
authorTaylor Blau <me@ttaylorr.com>
Fri, 12 Jun 2026 20:07:08 +0000 (16:07 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 Jun 2026 20:39:36 +0000 (13:39 -0700)
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 <szeder.dev@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-midx.sh
t/t5335-compact-multi-pack-index.sh

index e38c609604c3011d7363a9e01b4d6fe62b904025..b522dbdb0f431a6796918854f7a0a395e970d54d 100644 (file)
@@ -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" "$@"
+}
index ec1dafe89fcfce9d85344458efac488dc37e0cf3..6a4b799b9c9f491f484688b09b0eeaa48bad6515 100755 (executable)
@@ -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