Test for specific exit code
[stgit] / t / t1800-import.sh
CommitLineData
e4fc1f59
KH
1#!/bin/sh
2# Copyright (c) 2006 Karl Hasselström
3test_description='Test the import command'
4. ./test-lib.sh
5
6test_expect_success \
7 'Initialize the StGIT repository' \
8 '
fb336055 9 cp ../t1800-import/foo.txt . &&
e4fc1f59
KH
10 git add foo.txt &&
11 git commit -a -m "initial version" &&
12 stg init
13 '
14
15test_expect_success \
16 'Apply a patch created with "git diff"' \
17 '
18 stg import ../t1800-import/git-diff &&
19 [ $(git cat-file -p $(stg id) \
89f64744 20 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
e4fc1f59
KH
21 stg delete ..
22 '
23
24test_expect_success \
25 'Apply a patch created with GNU diff' \
26 '
27 stg import ../t1800-import/gnu-diff &&
28 [ $(git cat-file -p $(stg id) \
89f64744 29 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
e4fc1f59
KH
30 stg delete ..
31 '
32
33test_expect_success \
34 'Apply a patch created with "stg export"' \
35 '
36 stg import ../t1800-import/stg-export &&
37 [ $(git cat-file -p $(stg id) \
89f64744 38 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
e4fc1f59
KH
39 stg delete ..
40 '
41
42test_expect_success \
43 'Apply a patch from an 8bit-encoded e-mail' \
44 '
45 stg import -m ../t1800-import/email-8bit &&
46 [ $(git cat-file -p $(stg id) \
89f64744 47 | grep -c "tree 030be42660323ff2a1958f9ee79589a4f3fbee2f") = 1 ] &&
e4fc1f59 48 [ $(git cat-file -p $(stg id) \
89f64744 49 | grep -c "author Inge Ström <inge@power.com>") = 1 ] &&
e4fc1f59
KH
50 stg delete ..
51 '
52
53test_expect_success \
54 'Apply a patch from a QP-encoded e-mail' \
55 '
56 stg import -m ../t1800-import/email-qp &&
57 [ $(git cat-file -p $(stg id) \
89f64744 58 | grep -c "tree 030be42660323ff2a1958f9ee79589a4f3fbee2f") = 1 ] &&
e4fc1f59 59 [ $(git cat-file -p $(stg id) \
89f64744 60 | grep -c "author Inge Ström <inge@power.com>") = 1 ] &&
e4fc1f59
KH
61 stg delete ..
62 '
63
64test_expect_success \
65 'Apply several patches from an mbox file' \
66 '
67 stg import -M ../t1800-import/email-mbox &&
68 [ $(git cat-file -p $(stg id change-1) \
89f64744 69 | grep -c "tree 401bef82cd9fb403aba18f480a63844416a2e023") = 1 ] &&
e4fc1f59 70 [ $(git cat-file -p $(stg id change-1) \
89f64744 71 | grep -c "author Inge Ström <inge@power.com>") = 1 ] &&
e4fc1f59 72 [ $(git cat-file -p $(stg id change-2) \
89f64744 73 | grep -c "tree e49dbce010ec7f441015a8c64bce0b99108af4cc") = 1 ] &&
e4fc1f59 74 [ $(git cat-file -p $(stg id change-2) \
89f64744 75 | grep -c "author Inge Ström <inge@power.com>") = 1 ] &&
e4fc1f59 76 [ $(git cat-file -p $(stg id change-3) \
89f64744 77 | grep -c "tree 166bbaf27a44aee21ba78c98822a741e6f7d78f5") = 1 ] &&
e4fc1f59 78 [ $(git cat-file -p $(stg id change-3) \
89f64744 79 | grep -c "author Inge Ström <inge@power.com>") = 1 ] &&
e4fc1f59
KH
80 stg delete ..
81 '
82
354d2031
CW
83test_expect_success \
84 'Apply a bzip2 patch created with "git diff"' \
85 '
86 bzip2 -c ../t1800-import/git-diff >../t1800-import/bzip2-git-diff &&
87 stg import ../t1800-import/bzip2-git-diff &&
88 [ $(git cat-file -p $(stg id) \
89 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
90 rm ../t1800-import/bzip2-git-diff &&
91 stg delete ..
92 '
93test_expect_success \
94 'Apply a bzip2 patch with a .bz2 suffix' \
95 '
96 bzip2 -c ../t1800-import/git-diff >../t1800-import/git-diff.bz2 &&
97 stg import ../t1800-import/git-diff.bz2 &&
98 [ $(git cat-file -p $(stg id) \
99 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
100 rm ../t1800-import/git-diff.bz2 &&
101 stg delete ..
102 '
103
104test_expect_success \
105 'Apply a gzip patch created with GNU diff' \
106 '
107 gzip -c ../t1800-import/gnu-diff >../t1800-import/gzip-gnu-diff &&
108 stg import ../t1800-import/gzip-gnu-diff &&
109 [ $(git cat-file -p $(stg id) \
110 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
111 rm ../t1800-import/gzip-gnu-diff &&
112 stg delete ..
113 '
114test_expect_success \
115 'Apply a gzip patch with a .gz suffix' \
116 '
117 gzip -c ../t1800-import/gnu-diff >../t1800-import/gnu-diff.gz &&
118 stg import ../t1800-import/gnu-diff.gz &&
119 [ $(git cat-file -p $(stg id) \
120 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
121 rm ../t1800-import/gnu-diff.gz &&
122 stg delete ..
123 '
124
e4fc1f59 125test_done