Skip to content

Commit 05d90c1

Browse files
derrickstoleedscho
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 411ac53 commit 05d90c1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

t/t5538-push-shallow.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,37 @@ EOF
123123
git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
124124
)
125125
'
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+
126159
test_done

0 commit comments

Comments
 (0)