3 # Copyright (c) 2007 Shawn Pearce
6 test_description='test git-fast-import utility'
8 . ../diff-lib.sh ;# test-lib chdir's into trash
20 file5_data='an inline file.
21 we should see it later.'
31 cat >input <<INPUT_END
48 commit refs/heads/master
50 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
61 'A: create pack from stdin' \
62 'git-fast-import --export-marks=marks.out <input &&
63 git-whatchanged master'
66 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
69 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
70 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
76 'git-cat-file commit master | sed 1d >actual &&
77 diff -u expect actual'
86 'git-cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
87 diff -u expect actual'
89 echo "$file2_data" >expect
92 'git-cat-file blob master:file2 >actual && diff -u expect actual'
94 echo "$file3_data" >expect
97 'git-cat-file blob master:file3 >actual && diff -u expect actual'
99 printf "$file4_data" >expect
100 test_expect_success \
102 'git-cat-file blob master:file4 >actual && diff -u expect actual'
105 :2 `git-rev-parse --verify master:file2`
106 :3 `git-rev-parse --verify master:file3`
107 :4 `git-rev-parse --verify master:file4`
108 :5 `git-rev-parse --verify master^0`
110 test_expect_success \
111 'A: verify marks output' \
112 'diff -u expect marks.out'
119 cat >input <<INPUT_END
120 commit refs/heads/branch
122 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
127 from refs/heads/master
128 M 755 0000000000000000000000000000000000000001 zero1
131 test_expect_failure \
132 'B: fail on invalid blob sha1' \
133 'git-fast-import <input'
134 rm -f .git/objects/pack_* .git/objects/index_*
140 newf=`echo hi newf | git-hash-object -w --stdin`
141 oldf=`git-rev-parse --verify master:file2`
143 cat >input <<INPUT_END
144 commit refs/heads/branch
145 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
150 from refs/heads/master
151 M 644 $oldf file2/oldf
152 M 755 $newf file2/newf
156 test_expect_success \
157 'C: incremental import create pack from stdin' \
158 'git-fast-import <input &&
159 git-whatchanged branch'
160 test_expect_success \
162 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
163 test_expect_success \
164 'C: validate reuse existing blob' \
165 'test $newf = `git-rev-parse --verify branch:file2/newf`
166 test $oldf = `git-rev-parse --verify branch:file2/oldf`'
169 parent `git-rev-parse --verify master^0`
170 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
171 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
175 test_expect_success \
177 'git-cat-file commit branch | sed 1d >actual &&
178 diff -u expect actual'
181 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
182 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
183 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
185 git-diff-tree -M -r master branch >actual
186 test_expect_success \
187 'C: validate rename result' \
188 'compare_diff_raw expect actual'
195 cat >input <<INPUT_END
196 commit refs/heads/branch
197 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
202 from refs/heads/branch^0
203 M 644 inline newdir/interesting
208 M 755 inline newdir/exec.sh
214 test_expect_success \
215 'D: inline data in commit' \
216 'git-fast-import <input &&
217 git-whatchanged branch'
218 test_expect_success \
220 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
223 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
224 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
226 git-diff-tree -M -r branch^ branch >actual
227 test_expect_success \
228 'D: validate new files added' \
229 'compare_diff_raw expect actual'
231 echo "$file5_data" >expect
232 test_expect_success \
234 'git-cat-file blob branch:newdir/interesting >actual &&
235 diff -u expect actual'
237 echo "$file6_data" >expect
238 test_expect_success \
240 'git-cat-file blob branch:newdir/exec.sh >actual &&
241 diff -u expect actual'