Follow upstream changes -- rest
[git-darcs-import.git] / tests / filepath.sh
blob0ab530c47071e0a78e4545d40bc7c5b31ccfd497
1 #!/usr/bin/env bash
2 set -ev
4 # Some tests for proper handling of filepaths
6 not () { "$@" && exit 1 || :; }
8 portable_pwd () {
9 if uname | grep -i cygwin > /dev/null; then
10 cygpath -w `pwd`
11 else
12 pwd
15 # ugly hack for Cygwin and portable_pwd
16 IFS=''
17 DIR=`portable_pwd`
19 rm -rf temp1 temp2
21 # Make sure that init works with --repodir
22 darcs init --repodir=temp1
23 test -d temp1/_darcs
25 # add some meat to that repository
26 cd temp1
27 touch baz
28 darcs add baz
29 darcs record -m moo -a
30 cd ..
32 # ----------------------------------------------------------------------
33 # local vs remote filepaths
34 # ----------------------------------------------------------------------
36 # trick: OS-detection (if needed)
37 if echo $OS | grep -i windows; then
38 echo This test does not work on Windows
39 else
40 darcs get temp1 temp2
41 cd temp2
42 mkdir -p dir
43 darcs add dir
44 cd dir
45 touch foo:bar
46 darcs add --reserved-ok foo:bar
47 cd ../..
48 rm -rf temp2
51 # ----------------------------------------------------------------------
52 # repodir stuff
53 # ----------------------------------------------------------------------
54 mkdir -p temp1/non-darcs
55 # FIXME: This test does not seem to make much sense
56 # --repodir is not recursive
57 not darcs get temp1/non-darcs 2> log
58 grep "Not a repository" log
59 rm -rf temp1/non-darcs
60 rm -rf non-darcs
62 # get accepts --repodir.
63 darcs get --repodir=temp2 temp1 | grep -i "Finished getting"
64 test -d temp2/_darcs
65 rm -rf temp2
66 # get accepts absolute --repodir.
67 darcs get --repodir="${DIR}/temp2" temp1 | grep -i "Finished getting"
68 test -d temp2/_darcs
70 # changes accepts --repodir.
71 darcs changes --repodir=temp1 | grep -i "moo"
72 # changes accepts absolute --repo.
73 darcs changes --repo="${DIR}/temp1" | grep -i "moo"
74 # changes accepts relative --repo.
75 darcs changes --repo=temp1 | grep -i "moo"
76 # [issue467] context --repodir
77 darcs changes --context --repodir=temp1 | grep 'Context:'
79 # dist accepts --repodir.
80 darcs dist --repodir=temp1 | grep -i "Created dist"
82 # optimize accepts --repodir.
83 darcs optimize --reorder-patches --repodir=temp1 | grep -i "done optimizing"
85 # repair accepts --repodir.
86 darcs repair --repodir=temp1 | grep -i "already consistent"
88 # replace accepts --repodir.
89 darcs replace --repodir=temp1 foo bar
91 # setpref accepts --repodir.
92 darcs setpref --repodir=temp1 test echo | grep -i "Changing value of test"
94 # trackdown accepts --repodir.
95 darcs trackdown --repodir=temp1 | grep -i "Success!"
97 # ----------------------------------------------------------------------
98 # converting between absolute and relative paths
99 # ----------------------------------------------------------------------
101 darcs get temp1 temp3
102 cd temp3
103 mkdir -p a/b
104 cd ..
106 cd temp2
107 echo hello 1 >> baz
108 darcs record -m hello1 -a
109 echo hello 2 >> baz
110 darcs record -m hello2 -a
111 cd ..
113 # can handle .. path
114 cd temp3
115 darcs pull ../temp2 -p1 --all | grep -i 'Finished pulling'
116 darcs pull --dry-run | grep hello2
117 cd a/b
118 #[issue268] repodir with subdir
119 darcs pull --dry-run | grep hello2
120 cd ..
121 cd ..
123 rm -rf log temp1 temp2 temp3