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
15 function show_count
() {
16 commit_count
=$
(($commit_count+1))
17 printf " %d\r" $commit_count
23 local branch
=${name:0:1}
28 parents
="$parents -p $1"
32 echo "$text" > test.txt
33 git-update-index
--add test.txt
34 tree
=$
(git-write-tree
)
35 # make sure timestamps are in correct order
37 commit
=$
(echo "$text" | GIT_AUTHOR_DATE
=$sec \
38 git-commit-tree
$tree $parents 2>>log2.txt
)
40 echo $commit > .git
/refs
/heads
/$branch
41 eval ${branch}TIP
=$commit
44 function count_objects
() {
45 ls .git
/objects
/??
/* 2>>log2.txt |
wc -l |
tr -d " "
48 function test_expect_object_count
() {
52 output
="$(count_objects)"
54 "new object count $message" \
55 "test $count = $output"
58 function test_repack
() {
61 test_expect_success
"repack && prune-packed in $rep" \
62 '(git-repack && git-prune-packed)2>>log.txt'
65 function pull_to_client
() {
69 local no_strict_count_check
=$4
72 test_expect_success
"$number pull" \
73 "git-fetch-pack -v .. $heads > log.txt 2>&1"
74 case "$heads" in *A
*) echo $ATIP > .git
/refs
/heads
/A
;; esac
75 case "$heads" in *B
*) echo $BTIP > .git
/refs
/heads
/B
;; esac
76 git-symbolic-ref HEAD refs
/heads
/${heads:0:1}
77 test_expect_success
"fsck" 'git-fsck-objects --full > fsck.txt 2>&1'
78 test_expect_object_count
"after $number pull" $count
79 pack_count
=$
(grep Packing log.txt|
tr -dc "0-9")
80 test -z "$pack_count" && pack_count
=0
81 if [ -z "$no_strict_count_check" ]; then
82 test_expect_success
"minimal count" "test $count = $pack_count"
84 test $count != $pack_count && \
85 echo "WARNING: $pack_count objects transmitted, only $count of which were needed"
90 # Here begins the actual testing
92 # A1 - ... - A20 - A21
96 # client pulls A20, B1. Then tracks only B. Then pulls A.
101 git-init-db
2>> log2.txt
106 prev
=1; cur
=2; while [ $cur -le 10 ]; do
107 add A
$cur $
(eval echo \
$A$prev)
114 echo $ATIP > .git
/refs
/heads
/A
115 echo $BTIP > .git
/refs
/heads
/B
116 git-symbolic-ref HEAD refs
/heads
/B
118 pull_to_client
1st
"B A" $
((11*3))
120 (cd client
; test_repack client
)
124 prev
=1; cur
=2; while [ $cur -le 65 ]; do
125 add B
$cur $
(eval echo \
$B$prev)
130 pull_to_client
2nd
"B" $
((64*3))
132 (cd client
; test_repack client
)
134 pull_to_client
3rd
"A" $
((1*3)) # old fails