File: t2800-goto-subdir.sh

package info (click to toggle)
stgit 0.19-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,748 kB
  • sloc: python: 10,558; sh: 5,739; lisp: 2,678; makefile: 142; perl: 42
file content (72 lines) | stat: -rwxr-xr-x 1,461 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh

test_description='Run "stg goto" in a subdirectory'

. ./test-lib.sh

test_expect_success 'Initialize StGit stack' '
    stg init &&
    echo expected1.txt >> .git/info/exclude &&
    echo expected2.txt >> .git/info/exclude &&
    echo actual.txt >> .git/info/exclude &&
    mkdir foo &&
    for i in 1 2 3; do
        echo foo$i >> foo/bar &&
        stg new p$i -m p$i &&
        stg add foo/bar &&
        stg refresh
    done
'

cat > expected1.txt <<EOF
foo1
EOF
cat > expected2.txt <<EOF
bar
EOF
test_expect_success 'Goto in subdirectory (just pop)' '
    (cd foo && stg goto --keep p1) &&
    cat foo/bar > actual.txt &&
    test_cmp expected1.txt actual.txt &&
    ls foo > actual.txt &&
    test_cmp expected2.txt actual.txt
'

test_expect_success 'Prepare conflicting goto' '
    stg delete p2
'

# git gives this result before commit 606475f3 ...
cat > expected1a.txt <<EOF
foo1
<<<<<<< current:foo/bar
=======
foo2
foo3
>>>>>>> patched:foo/bar
EOF

# ... and this result after commit 606475f3.
cat > expected1b.txt <<EOF
foo1
<<<<<<< current
=======
foo2
foo3
>>>>>>> patched
EOF

cat > expected2.txt <<EOF
bar
EOF
test_expect_success 'Goto in subdirectory (conflicting push)' '
    (cd foo && stg goto --keep p3) ;
    [ $? -eq 3 ] &&
    cat foo/bar > actual.txt &&
    ( test_cmp expected1a.txt actual.txt \
      || test_cmp expected1b.txt actual.txt ) &&
    ls foo > actual.txt &&
    test_cmp expected2.txt actual.txt
'

test_done