t5538: add tests 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 <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
May 16, 2025 at 18:11 UTC
6e95bf80b5066abca85277bd8c142bf36c5fbe0d
1 file changed
+33
t/t5538-push-shallow.sh
+33
@@ -123,4 +123,37 @@ EOF
123
git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
124
)
125
'
126
+
127
+test_expect_success 'push new commit from shallow clone has correct object count' '
128
+ git init origin &&
129
+ test_commit -C origin a &&
130
+ test_commit -C origin b &&
131
+
132
+ git clone --depth=1 "file://$(pwd)/origin" client &&
133
+ git -C client checkout -b topic &&
134
+ git -C client commit --allow-empty -m "empty" &&
135
+ GIT_PROGRESS_DELAY=0 git -C client push --progress origin topic 2>err &&
136
+ test_grep "Enumerating objects: 1, done." err
137
+'
138
+
139
+test_expect_success 'push new commit from shallow clone has good deltas' '
140
+ git init base &&
141
+ test_seq 1 999 >base/a &&
142
+ test_commit -C base initial &&
143
+ git -C base add a &&
144
+ git -C base commit -m "big a" &&
145
+
146
+ git clone --depth=1 "file://$(pwd)/base" deltas &&
147
+ git -C deltas checkout -b deltas &&
148
+ test_seq 1 1000 >deltas/a &&
149
+ git -C deltas commit -a -m "bigger a" &&
150
+ GIT_PROGRESS_DELAY=0 git -C deltas push --progress origin deltas 2>err &&
151
+
152
+ test_grep "Enumerating objects: 5, done" err &&
153
+
154
+ # If the delta base is found, then this message uses "bytes".
155
+ # If the delta base is not found, then this message uses "KiB".
156
+ test_grep "Writing objects: .* bytes" err
157
+'
158
+
159
test_done