]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t5538: add tests to confirm deltas in shallow pushes
authorDerrick Stolee <stolee@gmail.com>
Fri, 16 May 2025 18:11:56 +0000 (18:11 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 May 2025 19:15:39 +0000 (12:15 -0700)
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 <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5538-push-shallow.sh

index e91fcc173e811664a2ca7fb504f551e79dfb89e5..c406f9d7ed5f09d40eea11cc720919ebfba9bb35 100755 (executable)
@@ -123,4 +123,37 @@ EOF
        git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
        )
 '
+
+test_expect_success 'push new commit from shallow clone has correct object count' '
+       git init origin &&
+       test_commit -C origin a &&
+       test_commit -C origin b &&
+
+       git clone --depth=1 "file://$(pwd)/origin" client &&
+       git -C client checkout -b topic &&
+       git -C client commit --allow-empty -m "empty" &&
+       GIT_PROGRESS_DELAY=0 git -C client push --progress origin topic 2>err &&
+       test_grep "Enumerating objects: 1, done." err
+'
+
+test_expect_success 'push new commit from shallow clone has good deltas' '
+       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_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