tests: fix diff order arguments in test_cmp
[git] / t / t9302-fast-import-unpack-limit.sh
1 #!/bin/sh
2 test_description='test git fast-import unpack limit'
3 . ./test-lib.sh
4
5 test_expect_success 'create loose objects on import' '
6         test_tick &&
7         cat >input <<-INPUT_END &&
8         commit refs/heads/master
9         committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
10         data <<COMMIT
11         initial
12         COMMIT
13
14         done
15         INPUT_END
16
17         git -c fastimport.unpackLimit=2 fast-import --done <input &&
18         git fsck --no-progress &&
19         test $(find .git/objects/?? -type f | wc -l) -eq 2 &&
20         test $(find .git/objects/pack -type f | wc -l) -eq 0
21 '
22
23 test_expect_success 'bigger packs are preserved' '
24         test_tick &&
25         cat >input <<-INPUT_END &&
26         commit refs/heads/master
27         committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
28         data <<COMMIT
29         incremental should create a pack
30         COMMIT
31         from refs/heads/master^0
32
33         commit refs/heads/branch
34         committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
35         data <<COMMIT
36         branch
37         COMMIT
38
39         done
40         INPUT_END
41
42         git -c fastimport.unpackLimit=2 fast-import --done <input &&
43         git fsck --no-progress &&
44         test $(find .git/objects/?? -type f | wc -l) -eq 2 &&
45         test $(find .git/objects/pack -type f | wc -l) -eq 2
46 '
47
48 test_expect_success 'lookups after checkpoint works' '
49         hello_id=$(echo hello | git hash-object --stdin -t blob) &&
50         id="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE" &&
51         before=$(git rev-parse refs/heads/master^0) &&
52         (
53                 cat <<-INPUT_END &&
54                 blob
55                 mark :1
56                 data 6
57                 hello
58
59                 commit refs/heads/master
60                 mark :2
61                 committer $id
62                 data <<COMMIT
63                 checkpoint after this
64                 COMMIT
65                 from refs/heads/master^0
66                 M 100644 :1 hello
67
68                 # pre-checkpoint
69                 cat-blob :1
70                 cat-blob $hello_id
71                 checkpoint
72                 # post-checkpoint
73                 cat-blob :1
74                 cat-blob $hello_id
75                 INPUT_END
76
77                 n=0 &&
78                 from=$before &&
79                 while test x"$from" = x"$before"
80                 do
81                         if test $n -gt 30
82                         then
83                                 echo >&2 "checkpoint did not update branch"
84                                 exit 1
85                         else
86                                 n=$(($n + 1))
87                         fi &&
88                         sleep 1 &&
89                         from=$(git rev-parse refs/heads/master^0)
90                 done &&
91                 cat <<-INPUT_END &&
92                 commit refs/heads/master
93                 committer $id
94                 data <<COMMIT
95                 make sure from "unpacked sha1 reference" works, too
96                 COMMIT
97                 from $from
98                 INPUT_END
99                 echo done
100         ) | git -c fastimport.unpackLimit=100 fast-import --done &&
101         test $(find .git/objects/?? -type f | wc -l) -eq 6 &&
102         test $(find .git/objects/pack -type f | wc -l) -eq 2
103 '
104
105 test_done