3 # Copyright (c) 2005 Johannes Schindelin
6 test_description
='Testing multi_ack pack fetching
11 # Test fetch-pack/upload-pack pair.
13 # Some convenience functions
18 branch
=`echo $name | sed -e 's/^\(.\).*$/\1/'`
23 parents
="$parents -p $1"
27 echo "$text" > test.txt
28 git-update-index
--add test.txt
29 tree
=$
(git-write-tree
)
30 # make sure timestamps are in correct order
32 commit
=$
(echo "$text" | GIT_AUTHOR_DATE
=$sec \
33 git-commit-tree
$tree $parents 2>>log2.txt
)
35 echo $commit > .git
/refs
/heads
/$branch
36 eval ${branch}TIP
=$commit
40 ls .git
/objects
/??
/* 2>>log2.txt |
wc -l |
tr -d " "
43 test_expect_object_count
() {
47 output
="$(count_objects)"
49 "new object count $message" \
50 "test $count = $output"
57 no_strict_count_check
=$4
60 test_expect_success
"$number pull" \
61 "git-fetch-pack -k -v .. $heads"
62 case "$heads" in *A
*) echo $ATIP > .git
/refs
/heads
/A
;; esac
63 case "$heads" in *B
*) echo $BTIP > .git
/refs
/heads
/B
;; esac
64 git-symbolic-ref HEAD refs
/heads
/`echo $heads | sed -e 's/^\(.\).*$/\1/'`
66 test_expect_success
"fsck" 'git-fsck-objects --full > fsck.txt 2>&1'
68 test_expect_success
'check downloaded results' \
69 'mv .git/objects/pack/pack-* . &&
70 p=`ls -1 pack-*.pack` &&
71 git-unpack-objects <$p &&
72 git-fsck-objects --full'
74 test_expect_success
"new object count after $number pull" \
75 'idx=`echo pack-*.idx` &&
76 pack_count=`git-show-index <$idx | wc -l` &&
77 test $pack_count = $count'
78 test -z "$pack_count" && pack_count
=0
79 if [ -z "$no_strict_count_check" ]; then
80 test_expect_success
"minimal count" "test $count = $pack_count"
82 test $count != $pack_count && \
83 echo "WARNING: $pack_count objects transmitted, only $count of which were needed"
89 # Here begins the actual testing
91 # A1 - ... - A20 - A21
95 # client pulls A20, B1. Then tracks only B. Then pulls A.
100 git-init-db
2>> log2.txt
105 prev
=1; cur
=2; while [ $cur -le 10 ]; do
106 add A
$cur $
(eval echo \
$A$prev)
113 echo $ATIP > .git
/refs
/heads
/A
114 echo $BTIP > .git
/refs
/heads
/B
115 git-symbolic-ref HEAD refs
/heads
/B
117 pull_to_client
1st
"B A" $
((11*3))
121 prev
=1; cur
=2; while [ $cur -le 65 ]; do
122 add B
$cur $
(eval echo \
$B$prev)
127 pull_to_client
2nd
"B" $
((64*3))
129 pull_to_client
3rd
"A" $
((1*3)) # old fails
131 test_expect_success
"clone shallow" "git-clone --depth 2 . shallow"
133 (cd shallow
; git-count-objects
-v) > count.shallow
135 test_expect_success
"clone shallow object count" \
136 "test \"in-pack: 18\" = \"$(grep in-pack count.shallow)\""
139 sed -e '/^in-pack:/d' -e '/^packs:/d' -e '/: 0$/d' "$1"
142 test_expect_success
"clone shallow object count (part 2)" '
143 test -z "$(count_output count.shallow)"
146 test_expect_success
"fsck in shallow repo" \
147 "(cd shallow; git-fsck-objects --full)"
154 test_expect_success
"pull in shallow repo" \
155 "(cd shallow; git pull .. B)"
157 (cd shallow
; git-count-objects
-v) > count.shallow
158 test_expect_success
"clone shallow object count" \
159 "test \"count: 6\" = \"$(grep count count.shallow)\""
164 test_expect_success
"deepening pull in shallow repo" \
165 "(cd shallow; git pull --depth 4 .. B)"
167 (cd shallow
; git-count-objects
-v) > count.shallow
168 test_expect_success
"clone shallow object count" \
169 "test \"count: 12\" = \"$(grep count count.shallow)\""
171 test_expect_success
"deepening fetch in shallow repo" \
172 "(cd shallow; git fetch --depth 4 .. A:A)"
174 (cd shallow
; git-count-objects
-v) > count.shallow
175 test_expect_success
"clone shallow object count" \
176 "test \"count: 18\" = \"$(grep count count.shallow)\""
178 test_expect_failure
"pull in shallow repo with missing merge base" \
179 "(cd shallow; git pull --depth 4 .. A)"