Commit | Line | Data |
---|---|---|
f837ca5e KH |
1 | #!/bin/sh |
2 | ||
3 | test_description='"stg refresh" with removed files' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | # Ignore our own temp files. | |
8 | cat >> .git/info/exclude <<EOF | |
9 | expected*.txt | |
10 | files*.txt | |
11 | status*.txt | |
12 | EOF | |
13 | ||
14 | reset () { | |
15 | stg pop -a > /dev/null | |
16 | git reset --hard > /dev/null | |
17 | } | |
18 | ||
19 | test_expect_success 'Initialize StGit stack' ' | |
20 | stg init && | |
21 | echo x > x.txt && | |
22 | echo y > y.txt && | |
23 | git add x.txt y.txt && | |
24 | git commit -m "Add some files" | |
25 | ' | |
26 | ||
27 | cat > expected0.txt <<EOF | |
28 | D y.txt | |
29 | EOF | |
30 | printf '' > expected1.txt | |
850c3a89 | 31 | test_expect_success 'git rm a file' ' |
f837ca5e KH |
32 | stg new -m p0 && |
33 | git rm y.txt && | |
34 | stg status > status0.txt && | |
35 | test_cmp expected0.txt status0.txt && | |
36 | stg refresh && | |
37 | stg status > status1.txt && | |
38 | test_cmp expected1.txt status1.txt && | |
39 | stg files | sort > files.txt && | |
40 | test_cmp expected0.txt files.txt | |
41 | ' | |
42 | ||
43 | reset | |
44 | ||
45 | cat > expected0.txt <<EOF | |
46 | D y.txt | |
47 | M x.txt | |
48 | EOF | |
49 | printf '' > expected1.txt | |
850c3a89 | 50 | test_expect_success 'git rm a file together with other changes' ' |
f837ca5e KH |
51 | stg new -m p1 && |
52 | echo x2 >> x.txt && | |
53 | git rm y.txt && | |
54 | stg status > status0.txt && | |
55 | test_cmp expected0.txt status0.txt && | |
56 | stg refresh && | |
57 | stg status > status1.txt && | |
58 | test_cmp expected1.txt status1.txt && | |
59 | stg files | sort > files.txt && | |
60 | test_cmp expected0.txt files.txt | |
61 | ' | |
62 | ||
63 | reset | |
64 | ||
65 | cat > expected0.txt <<EOF | |
66 | D y.txt | |
67 | EOF | |
68 | printf '' > expected1.txt | |
69 | test_expect_success 'rm a file' ' | |
70 | stg new -m p2 && | |
71 | rm y.txt && | |
72 | stg status > status0.txt && | |
73 | test_cmp expected0.txt status0.txt && | |
74 | stg refresh && | |
75 | stg status > status1.txt && | |
76 | test_cmp expected1.txt status1.txt && | |
77 | stg files | sort > files.txt && | |
78 | test_cmp expected0.txt files.txt | |
79 | ' | |
80 | ||
81 | reset | |
82 | ||
83 | cat > expected0.txt <<EOF | |
84 | D y.txt | |
85 | M x.txt | |
86 | EOF | |
87 | printf '' > expected1.txt | |
88 | test_expect_success 'rm a file together with other changes' ' | |
89 | stg new -m p3 && | |
90 | echo x2 >> x.txt && | |
91 | rm y.txt && | |
92 | stg status > status0.txt && | |
93 | test_cmp expected0.txt status0.txt && | |
94 | stg refresh && | |
95 | stg status > status1.txt && | |
96 | test_cmp expected1.txt status1.txt && | |
97 | stg files | sort > files.txt && | |
98 | test_cmp expected0.txt files.txt | |
99 | ' | |
100 | ||
101 | test_done |