chiark / gitweb /
stgit.el: Add "d" for a few diff commands, similar to git.el
[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
47d51d91
CM
24test_expect_success \
25 'Apply a patch created with "git diff" from a subdirectory' \
26 '
27 mkdir subdir && cd subdir &&
28 stg import ../../t1800-import/git-diff &&
29 [ $(git cat-file -p $(stg id) \
30 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
31 stg delete .. &&
32 cd ..
33 '
34
e4fc1f59
KH
35test_expect_success \
36 'Apply a patch created with GNU diff' \
37 '
38 stg import ../t1800-import/gnu-diff &&
39 [ $(git cat-file -p $(stg id) \
89f64744 40 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
e4fc1f59
KH
41 stg delete ..
42 '
43
44test_expect_success \
45 'Apply a patch created with "stg export"' \
46 '
47 stg import ../t1800-import/stg-export &&
48 [ $(git cat-file -p $(stg id) \
89f64744 49 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
e4fc1f59
KH
50 stg delete ..
51 '
52
53test_expect_success \
54 'Apply a patch from an 8bit-encoded e-mail' \
55 '
56 stg import -m ../t1800-import/email-8bit &&
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 a patch from a QP-encoded e-mail' \
66 '
67 stg import -m ../t1800-import/email-qp &&
68 [ $(git cat-file -p $(stg id) \
89f64744 69 | grep -c "tree 030be42660323ff2a1958f9ee79589a4f3fbee2f") = 1 ] &&
e4fc1f59 70 [ $(git cat-file -p $(stg id) \
89f64744 71 | grep -c "author Inge Ström <inge@power.com>") = 1 ] &&
e4fc1f59
KH
72 stg delete ..
73 '
74
75test_expect_success \
76 'Apply several patches from an mbox file' \
77 '
78 stg import -M ../t1800-import/email-mbox &&
79 [ $(git cat-file -p $(stg id change-1) \
89f64744 80 | grep -c "tree 401bef82cd9fb403aba18f480a63844416a2e023") = 1 ] &&
e4fc1f59 81 [ $(git cat-file -p $(stg id change-1) \
89f64744 82 | grep -c "author Inge Ström <inge@power.com>") = 1 ] &&
e4fc1f59 83 [ $(git cat-file -p $(stg id change-2) \
89f64744 84 | grep -c "tree e49dbce010ec7f441015a8c64bce0b99108af4cc") = 1 ] &&
e4fc1f59 85 [ $(git cat-file -p $(stg id change-2) \
89f64744 86 | grep -c "author Inge Ström <inge@power.com>") = 1 ] &&
e4fc1f59 87 [ $(git cat-file -p $(stg id change-3) \
89f64744 88 | grep -c "tree 166bbaf27a44aee21ba78c98822a741e6f7d78f5") = 1 ] &&
e4fc1f59 89 [ $(git cat-file -p $(stg id change-3) \
89f64744 90 | grep -c "author Inge Ström <inge@power.com>") = 1 ] &&
e4fc1f59
KH
91 stg delete ..
92 '
93
354d2031
CW
94test_expect_success \
95 'Apply a bzip2 patch created with "git diff"' \
96 '
97 bzip2 -c ../t1800-import/git-diff >../t1800-import/bzip2-git-diff &&
98 stg import ../t1800-import/bzip2-git-diff &&
99 [ $(git cat-file -p $(stg id) \
100 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
101 rm ../t1800-import/bzip2-git-diff &&
102 stg delete ..
103 '
104test_expect_success \
105 'Apply a bzip2 patch with a .bz2 suffix' \
106 '
107 bzip2 -c ../t1800-import/git-diff >../t1800-import/git-diff.bz2 &&
108 stg import ../t1800-import/git-diff.bz2 &&
109 [ $(git cat-file -p $(stg id) \
110 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
111 rm ../t1800-import/git-diff.bz2 &&
112 stg delete ..
113 '
114
115test_expect_success \
116 'Apply a gzip patch created with GNU diff' \
117 '
118 gzip -c ../t1800-import/gnu-diff >../t1800-import/gzip-gnu-diff &&
119 stg import ../t1800-import/gzip-gnu-diff &&
120 [ $(git cat-file -p $(stg id) \
121 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
122 rm ../t1800-import/gzip-gnu-diff &&
123 stg delete ..
124 '
125test_expect_success \
126 'Apply a gzip patch with a .gz suffix' \
127 '
128 gzip -c ../t1800-import/gnu-diff >../t1800-import/gnu-diff.gz &&
129 stg import ../t1800-import/gnu-diff.gz &&
130 [ $(git cat-file -p $(stg id) \
131 | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
132 rm ../t1800-import/gnu-diff.gz &&
133 stg delete ..
134 '
135
972de1db
CW
136test_expect_success \
137 'apply a series from a tarball' \
138 '
139 rm -f jabberwocky.txt && touch jabberwocky.txt &&
140 git add jabberwocky.txt && git commit -m "empty file" jabberwocky.txt &&
141 (cd ../t1800-import; tar -cjf jabberwocky.tar.bz2 patches) &&
142 stg import --series ../t1800-import/jabberwocky.tar.bz2
143 [ $(git cat-file -p $(stg id) \
144 | grep -c "tree 2c33937252a21f1550c0bf21f1de534b68f69635") = 1 ] &&
145 rm ../t1800-import/jabberwocky.tar.bz2
146 '
147
e4fc1f59 148test_done