Follow upstream changes -- Bytestring updates
[git-darcs-import.git] / tests / match.sh
bloba34af3905d794f99cc4eecb31e30c24fd220bc92
1 #!/usr/bin/env bash
2 set -ev
4 # Some tests for the '--match' flag
6 not () { "$@" && exit 1 || :; }
8 # set up the repository
9 rm -rf temp1 # another script may have left a mess.
10 mkdir temp1
11 cd temp1
12 darcs init
13 cd ..
15 # create three patches - the property we exploit to determine
16 # if a matcher does the right thing is that each patch has a
17 # different author
18 cd temp1
19 touch bar
20 darcs add bar
21 darcs record -a -m "first patch" bar -A author1
22 echo foo > bar
23 darcs record -a -m "\"second\" \\ patch" bar -A author2
24 echo blop > bar
25 darcs record -a -m "second" bar -A author3
26 cd ..
28 # -------------------------------------------------------------------
29 # single matchers
30 # -------------------------------------------------------------------
32 cd temp1
33 # matching on author really matches on that, and not something else
34 darcs changes --match='author "first patch"' > log
35 not grep '.' log
36 # normal changes shows both authors and patch names
37 darcs changes > log
38 grep author1 log
39 grep author2 log
40 grep author3 log
41 grep 'first patch' log
42 grep '"second" \\ patch' log
43 grep -v patch log | grep second
44 # exact
45 darcs changes --match='exact second' > log
46 not grep author1 log
47 not grep author2 log
48 grep author3 log
49 # name
50 darcs changes --match='name second' > log
51 not grep author1 log
52 grep author2 log
53 grep author2 log
54 # author
55 darcs changes --match='author author1' > log
56 grep author1 log
57 not grep author2 log
58 not grep author3 log
59 #hash
60 darcs changes --xml-output --match='exact "\"second\" \ patch"' > log
61 hash=`grep hash log | sed -e "s/.*hash='//" -e "s/'.*//"`
62 echo $hash
63 darcs changes --match="hash $hash"
64 not grep author1 log
65 grep author2 log
66 not grep author3 log
67 cd ..
69 # -------------------------------------------------------------------
70 # matching on combinations
72 # uses the setup from the atomic patches
73 # -------------------------------------------------------------------
75 cd temp1
76 # or
77 darcs changes --match='author author1 || author author2' > log
78 grep author1 log
79 grep author2 log
80 not grep author3 log
81 # and
82 darcs changes --match='name second && author author2' > log
83 not grep author1 log
84 grep author2 log
85 not grep author3 log
86 # not
87 darcs changes --match='not name second' > log
88 grep author1 log
89 not grep author2 log
90 not grep author3 log
91 # grouping
92 darcs changes --match='(not name second) || (author author3)' > log
93 grep author1 log
94 not grep author2 log
95 grep author3 log
96 cd ..
98 rm -rf temp1