From 423e4cdb537fdfcbcfee36df2a73bbe71764098a Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 22 Oct 2024 12:05:27 -0400 Subject: [PATCH] t5538: add test to confirm deltas in shallow pushes It can be notoriously difficult to detect if delta bases are being computed properly during 'git push'. Construct an example where it will make a kilobyte worth of difference when a delta base is not found. We can then use the progress indicators to distinguish between bytes and KiB depending on whether the delta base is found and used. Signed-off-by: Derrick Stolee --- t/t5538-push-shallow.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/t/t5538-push-shallow.sh b/t/t5538-push-shallow.sh index 1e37df1f31f891..eed75deddc856b 100755 --- a/t/t5538-push-shallow.sh +++ b/t/t5538-push-shallow.sh @@ -137,4 +137,25 @@ test_expect_success 'push new commit from shallow clone to origin is efficient' test_grep "Enumerating objects: 1, done." err ' +test_expect_success 'push new commit from shallow clone to origin is efficient' ' + git init base && + test_seq 1 999 >base/a && + test_commit -C base initial && + git -C base add a && + git -C base commit -m "big a" && + + git clone --depth=1 "file://$(pwd)/base" deltas && + git -C deltas checkout -b deltas && + test_seq 1 1000 >deltas/a && + git -C deltas commit -a -m "bigger a" && + GIT_TRACE2_PERF="$(pwd)/trace.txt" \ + GIT_PROGRESS_DELAY=0 git -C deltas push --progress origin deltas 2>err && + + test_grep "Enumerating objects: 5, done" err && + + # If the delta base is found, then this message uses "bytes". + # If the delta base is not found, then this message uses "KiB". + test_grep "Writing objects: .* bytes" err +' + test_done