stgit.el: Break out stgit-sort-patches to a separate function for future reuse
[stgit] / t / t2800-goto-subdir.sh
CommitLineData
ab96cd1c
KH
1#!/bin/sh
2
3test_description='Run "stg goto" in a subdirectory'
4
5. ./test-lib.sh
6
7test_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 git add foo/bar &&
17 stg refresh
18 done
19'
20
21cat > expected1.txt <<EOF
22foo1
23EOF
24cat > expected2.txt <<EOF
25bar
26EOF
8d96d568 27test_expect_success 'Goto in subdirectory (just pop)' '
ab96cd1c
KH
28 (cd foo && stg goto p1) &&
29 cat foo/bar > actual.txt &&
d9b2f20a 30 test_cmp expected1.txt actual.txt &&
ab96cd1c 31 ls foo > actual.txt &&
d9b2f20a 32 test_cmp expected2.txt actual.txt
ab96cd1c
KH
33'
34
35test_expect_success 'Prepare conflicting goto' '
36 stg delete p2
37'
38
39cat > expected1.txt <<EOF
40foo1
41<<<<<<< current:foo/bar
42=======
43foo2
44foo3
45>>>>>>> patched:foo/bar
46EOF
47cat > expected2.txt <<EOF
48bar
49EOF
8d96d568 50test_expect_success 'Goto in subdirectory (conflicting push)' '
ab96cd1c
KH
51 (cd foo && stg goto p3) ;
52 [ $? -eq 3 ] &&
53 cat foo/bar > actual.txt &&
d9b2f20a 54 test_cmp expected1.txt actual.txt &&
ab96cd1c 55 ls foo > actual.txt &&
d9b2f20a 56 test_cmp expected2.txt actual.txt
ab96cd1c
KH
57'
58
59test_done