More robust setup.py code generation
[stgit.git] / t / t2800-goto-subdir.sh
blob5ac77cc081b1772678699f495d9be011c0c4a838
1 #!/bin/sh
3 test_description='Run "stg goto" in a subdirectory'
5 . ./test-lib.sh
7 test_expect_success 'Initialize StGit stack' '
8 stg init &&
9 echo expected1.txt >> .git/info/exclude &&
10 echo expected2.txt >> .git/info/exclude &&
11 echo actual.txt >> .git/info/exclude &&
12 mkdir foo &&
13 for i in 1 2 3; do
14 echo foo$i >> foo/bar &&
15 stg new p$i -m p$i &&
16 stg add foo/bar &&
17 stg refresh
18 done
21 cat > expected1.txt <<EOF
22 foo1
23 EOF
24 cat > expected2.txt <<EOF
25 bar
26 EOF
27 test_expect_success 'Goto in subdirectory (just pop)' '
28 (cd foo && stg goto --keep p1) &&
29 cat foo/bar > actual.txt &&
30 test_cmp expected1.txt actual.txt &&
31 ls foo > actual.txt &&
32 test_cmp expected2.txt actual.txt
35 test_expect_success 'Prepare conflicting goto' '
36 stg delete p2
39 # git gives this result before commit 606475f3 ...
40 cat > expected1a.txt <<EOF
41 foo1
42 <<<<<<< current:foo/bar
43 =======
44 foo2
45 foo3
46 >>>>>>> patched:foo/bar
47 EOF
49 # ... and this result after commit 606475f3.
50 cat > expected1b.txt <<EOF
51 foo1
52 <<<<<<< current
53 =======
54 foo2
55 foo3
56 >>>>>>> patched
57 EOF
59 cat > expected2.txt <<EOF
60 bar
61 EOF
62 test_expect_success 'Goto in subdirectory (conflicting push)' '
63 (cd foo && stg goto --keep p3) ;
64 [ $? -eq 3 ] &&
65 cat foo/bar > actual.txt &&
66 ( test_cmp expected1a.txt actual.txt \
67 || test_cmp expected1b.txt actual.txt ) &&
68 ls foo > actual.txt &&
69 test_cmp expected2.txt actual.txt
72 test_done