2 test_description='"notmuch git" to save and restore tags'
3 . $(dirname "$0")/test-lib.sh || exit 1
5 if [ $NOTMUCH_HAVE_SFSEXP -ne 1 ]; then
6 printf "Skipping due to missing sfsexp library\n"
12 git config --global user.email notmuch@example.org
13 git config --global user.name "Notmuch Test Suite"
15 test_begin_subtest "init"
16 test_expect_success "notmuch git -p '' -C remote.git init"
18 test_begin_subtest "init (git.path)"
19 notmuch config set git.path configured.git
21 notmuch config set git.path
22 output=$(git -C configured.git rev-parse --is-bare-repository)
23 test_expect_equal "$output" "true"
25 test_begin_subtest "clone"
26 test_expect_success "notmuch git -p '' -C tags.git clone remote.git"
28 test_begin_subtest "commit"
29 notmuch git -C tags.git commit
30 git -C tags.git ls-tree -r --name-only HEAD | xargs dirname | sort -u | sed s,tags/,id:, > OUTPUT
31 notmuch search --output=messages '*' | sort > EXPECTED
32 test_expect_equal_file_nonempty EXPECTED OUTPUT
34 test_begin_subtest "commit, with quoted tag"
35 notmuch git -C clone2.git clone tags.git
36 git -C clone2.git ls-tree -r --name-only HEAD | grep /inbox > BEFORE
37 notmuch tag '+"quoted tag"' '*'
38 notmuch git -C clone2.git commit
39 notmuch tag '-"quoted tag"' '*'
40 git -C clone2.git ls-tree -r --name-only HEAD | grep /inbox > AFTER
41 test_expect_equal_file_nonempty BEFORE AFTER
43 test_begin_subtest "commit (incremental)"
44 notmuch tag +test id:20091117190054.GU3165@dottiness.seas.harvard.edu
45 notmuch git -C tags.git commit
46 git -C tags.git ls-tree -r --name-only HEAD |
47 grep 20091117190054 | sort > OUTPUT
48 echo "--------------------------------------------------" >> OUTPUT
49 notmuch tag -test id:20091117190054.GU3165@dottiness.seas.harvard.edu
50 notmuch git -C tags.git commit
51 git -C tags.git ls-tree -r --name-only HEAD |
52 grep 20091117190054 | sort >> OUTPUT
54 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/inbox
55 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/signed
56 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/test
57 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/unread
58 --------------------------------------------------
59 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/inbox
60 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/signed
61 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/unread
63 test_expect_equal_file_nonempty EXPECTED OUTPUT
65 test_begin_subtest "commit (change prefix)"
66 notmuch tag +test::one id:20091117190054.GU3165@dottiness.seas.harvard.edu
67 notmuch git -C tags.git -p 'test::' commit
68 git -C tags.git ls-tree -r --name-only HEAD |
69 grep 20091117190054 | sort > OUTPUT
70 echo "--------------------------------------------------" >> OUTPUT
71 notmuch tag -test::one id:20091117190054.GU3165@dottiness.seas.harvard.edu
72 notmuch git -C tags.git commit
73 git -C tags.git ls-tree -r --name-only HEAD |
74 grep 20091117190054 | sort >> OUTPUT
76 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/one
77 --------------------------------------------------
78 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/inbox
79 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/signed
80 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/unread
82 test_expect_equal_file_nonempty EXPECTED OUTPUT
84 test_begin_subtest "checkout"
86 notmuch tag -inbox '*'
87 notmuch git -C tags.git checkout
89 test_expect_equal_file_nonempty BEFORE AFTER
91 test_begin_subtest "archive"
92 notmuch git -C tags.git archive | tar tf - | \
93 grep 20091117190054.GU3165@dottiness.seas.harvard.edu | sort > OUTPUT
95 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/
96 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/inbox
97 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/signed
98 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/unread
100 notmuch git -C tags.git checkout
101 test_expect_equal_file EXPECTED OUTPUT
103 test_begin_subtest "status"
104 notmuch tag +test id:20091117190054.GU3165@dottiness.seas.harvard.edu
105 notmuch git -C tags.git status > OUTPUT
107 A 20091117190054.GU3165@dottiness.seas.harvard.edu test
109 notmuch git -C tags.git checkout
110 test_expect_equal_file EXPECTED OUTPUT
112 test_begin_subtest "status (global config argument)"
113 cp notmuch-config notmuch-config.new
114 notmuch --config=notmuch-config.new config set git.path tags.git
115 notmuch tag +test id:20091117190054.GU3165@dottiness.seas.harvard.edu
116 notmuch --config=./notmuch-config.new git status > OUTPUT
118 A 20091117190054.GU3165@dottiness.seas.harvard.edu test
120 notmuch --config=notmuch-config.new git checkout
121 test_expect_equal_file EXPECTED OUTPUT
123 test_begin_subtest "fetch"
124 notmuch tag +test2 id:20091117190054.GU3165@dottiness.seas.harvard.edu
125 notmuch git -C remote.git commit
126 notmuch tag -test2 id:20091117190054.GU3165@dottiness.seas.harvard.edu
127 notmuch git -C tags.git fetch
128 notmuch git -C tags.git status > OUTPUT
130 a 20091117190054.GU3165@dottiness.seas.harvard.edu test2
132 notmuch git -C tags.git checkout
133 test_expect_equal_file EXPECTED OUTPUT
135 test_begin_subtest "merge"
136 notmuch git -C tags.git merge
137 notmuch dump id:20091117190054.GU3165@dottiness.seas.harvard.edu | grep -v '^#' > OUTPUT
139 +inbox +signed +test2 +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu
141 test_expect_equal_file EXPECTED OUTPUT
143 test_begin_subtest "push"
144 notmuch tag +test3 id:20091117190054.GU3165@dottiness.seas.harvard.edu
145 notmuch git -C tags.git commit
146 notmuch tag -test3 id:20091117190054.GU3165@dottiness.seas.harvard.edu
147 notmuch git -C tags.git push
148 notmuch git -C remote.git checkout
149 notmuch dump id:20091117190054.GU3165@dottiness.seas.harvard.edu | grep -v '^#' > OUTPUT
151 +inbox +signed +test2 +test3 +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu
153 test_expect_equal_file EXPECTED OUTPUT
155 test_begin_subtest "environment passed through when run as 'notmuch git'"
156 env NOTMUCH_GIT_DIR=foo NOTMUCH_GIT_PREFIX=bar NOTMUCH_PROFILE=default notmuch git -C tags.git -p '' -ldebug status |& \
157 grep '^env ' | notmuch_dir_sanitize > OUTPUT
159 env NOTMUCH_GIT_DIR = foo
160 env NOTMUCH_GIT_PREFIX = bar
161 env NOTMUCH_PROFILE = default
162 env NOTMUCH_CONFIG = CWD/notmuch-config
164 test_expect_equal_file EXPECTED OUTPUT
166 test_begin_subtest "--nmbug argument sets defaults"
167 notmuch git -ldebug --nmbug status |& grep '^\(prefix\|repository\)' | notmuch_dir_sanitize > OUTPUT
170 repository = CWD/home/.nmbug
172 test_expect_equal_file EXPECTED OUTPUT
174 test_begin_subtest "invoke as nmbug sets defaults"
175 "$NOTMUCH_BUILDDIR"/nmbug -ldebug status |& grep '^\(prefix\|repository\)' | notmuch_dir_sanitize > OUTPUT
178 repository = CWD/home/.nmbug
180 test_expect_equal_file EXPECTED OUTPUT
182 test_begin_subtest "env variable NOTMUCH_GIT_DIR works when invoked as nmbug"
183 NOTMUCH_GIT_DIR=`pwd`/foo "$NOTMUCH_BUILDDIR"/nmbug -ldebug status |& grep '^repository' | notmuch_dir_sanitize > OUTPUT
187 test_expect_equal_file EXPECTED OUTPUT
189 test_begin_subtest "env variable NOTMUCH_GIT_DIR works when invoked as 'notmuch git'"
190 NOTMUCH_GIT_DIR=`pwd`/remote.git notmuch git -ldebug status |& grep '^repository' | notmuch_dir_sanitize > OUTPUT
192 repository = CWD/remote.git
194 test_expect_equal_file EXPECTED OUTPUT
197 test_begin_subtest "env variable NOTMUCH_GIT_DIR overrides config when invoked as 'nmbug'"
198 notmuch config set git.path `pwd`/bar
199 NOTMUCH_GIT_DIR=`pwd`/remote.git "$NOTMUCH_BUILDDIR"/nmbug -ldebug status |& grep '^repository' | notmuch_dir_sanitize > OUTPUT
200 notmuch config set git.path
202 repository = CWD/remote.git
204 test_expect_equal_file EXPECTED OUTPUT
206 test_begin_subtest "env variable NOTMUCH_GIT_DIR overrides config when invoked as 'notmuch git'"
207 notmuch config set git.path `pwd`/bar
208 NOTMUCH_GIT_DIR=`pwd`/remote.git notmuch git -ldebug status |& grep '^repository' | notmuch_dir_sanitize > OUTPUT
209 notmuch config set git.path
211 repository = CWD/remote.git
213 test_expect_equal_file EXPECTED OUTPUT
215 test_begin_subtest "env variable NOTMUCH_GIT_PREFIX works when invoked as 'nmbug'"
216 NOTMUCH_GIT_PREFIX=env:: "$NOTMUCH_BUILDDIR"/nmbug -ldebug status |& grep '^prefix' | notmuch_dir_sanitize > OUTPUT
220 test_expect_equal_file EXPECTED OUTPUT
222 test_begin_subtest "env variable NOTMUCH_GIT_PREFIX works when invoked as nmbug"
223 NOTMUCH_GIT_PREFIX=foo:: "$NOTMUCH_BUILDDIR"/nmbug -ldebug status |& grep '^prefix' | notmuch_dir_sanitize > OUTPUT
227 test_expect_equal_file EXPECTED OUTPUT
229 test_begin_subtest "env variable NOTMUCH_GIT_PREFIX overrides config when invoked as 'nmbug'"
230 notmuch config set git.tag_prefix config::
231 NOTMUCH_GIT_PREFIX=env:: "$NOTMUCH_BUILDDIR"/nmbug -ldebug status |& grep '^prefix' | notmuch_dir_sanitize > OUTPUT
232 notmuch config set git.path
236 test_expect_equal_file EXPECTED OUTPUT
238 test_begin_subtest "env variable NOTMUCH_GIT_PREFIX overrides config when invoked as 'notmuch git'"
239 notmuch config set git.tag_prefix config::
240 NOTMUCH_GIT_PREFIX=env:: notmuch git -ldebug status |& grep '^prefix' | notmuch_dir_sanitize > OUTPUT
241 notmuch config set git.path
245 test_expect_equal_file EXPECTED OUTPUT
248 test_begin_subtest "init, xdg default location"
249 repo=home/.local/share/notmuch/default/git
250 notmuch git -ldebug init |& grep '^repository' | notmuch_dir_sanitize > OUTPUT
251 git -C $repo rev-parse --absolute-git-dir | notmuch_dir_sanitize >> OUTPUT
253 repository = CWD/$repo
256 test_expect_equal_file EXPECTED OUTPUT
258 test_begin_subtest "init, xdg default location, with profile"
259 repo=home/.local/share/notmuch/work/git
260 NOTMUCH_PROFILE=work notmuch git -ldebug init |& grep '^repository' | notmuch_dir_sanitize > OUTPUT
261 git -C $repo rev-parse --absolute-git-dir | notmuch_dir_sanitize >> OUTPUT
263 repository = CWD/$repo
266 test_expect_equal_file EXPECTED OUTPUT
268 test_begin_subtest "init, configured location"
270 notmuch config set git.path `pwd`/$repo
271 notmuch git -ldebug init |& grep '^repository' | notmuch_dir_sanitize > OUTPUT
272 notmuch config set git.path
273 git -C $repo rev-parse --absolute-git-dir | notmuch_dir_sanitize >> OUTPUT
275 repository = CWD/$repo
278 test_expect_equal_file EXPECTED OUTPUT
280 test_begin_subtest "configured tag prefix"
281 notmuch config set git.tag_prefix test::
282 notmuch git -ldebug status |& grep '^prefix' > OUTPUT
283 notmuch config set git.tag_prefix
287 test_expect_equal_file EXPECTED OUTPUT