chiark / gitweb /
stgit.el: Add "d" for a few diff commands, similar to git.el
[stgit] / t / t2700-refresh.sh
CommitLineData
38baedf2
DK
1#!/bin/sh
2
3test_description='Run "stg refresh"'
4
5. ./test-lib.sh
6
7test_expect_success 'Initialize StGit stack' '
8 stg init &&
c3a72ae1 9 echo expected*.txt >> .git/info/exclude &&
38baedf2 10 echo patches.txt >> .git/info/exclude &&
c3a72ae1
PO
11 echo show.txt >> .git/info/exclude &&
12 echo diff.txt >> .git/info/exclude &&
38baedf2
DK
13 stg new p0 -m "base" &&
14 for i in 1 2 3; do
15 echo base >> foo$i.txt &&
16 git add foo$i.txt
17 done
18 stg refresh &&
19 for i in 1 2 3; do
20 stg new p$i -m "foo $i" &&
21 echo "foo $i" >> foo$i.txt &&
22 stg refresh
23 done
24'
25
26cat > expected.txt <<EOF
27p0
28p3
29EOF
30test_expect_success 'Refresh top patch' '
31 echo bar 3 >> foo3.txt &&
32 stg refresh &&
33 stg status &&
34 test -z "$(stg status)" &&
35 stg patches foo3.txt > patches.txt &&
d9b2f20a 36 test_cmp expected.txt patches.txt
38baedf2
DK
37'
38
39cat > expected.txt <<EOF
40p0
41p2
42EOF
43test_expect_success 'Refresh middle patch' '
44 stg status &&
45 echo bar 2 >> foo2.txt &&
46 stg refresh -p p2 &&
47 stg status &&
48 test -z "$(stg status)" &&
49 stg patches foo2.txt > patches.txt &&
d9b2f20a 50 test_cmp expected.txt patches.txt
38baedf2
DK
51'
52
53cat > expected.txt <<EOF
54p0
55p1
56EOF
57test_expect_success 'Refresh bottom patch' '
58 stg status &&
59 echo bar 1 >> foo1.txt &&
60 stg refresh -p p1 &&
61 stg status &&
62 test -z "$(stg status)" &&
63 stg patches foo1.txt > patches.txt &&
d9b2f20a 64 test_cmp expected.txt patches.txt
38baedf2
DK
65'
66
c3a72ae1
PO
67cat > expected.txt <<EOF
68p0
69p1
70p4
71EOF
72cat > expected2.txt <<EOF
73diff --git a/foo1.txt b/foo1.txt
74index 728535d..6f34984 100644
75--- a/foo1.txt
76+++ b/foo1.txt
77@@ -1,3 +1,4 @@
78 base
79 foo 1
80 bar 1
81+baz 1
82EOF
83cat > expected3.txt <<EOF
84diff --git a/foo1.txt b/foo1.txt
85index 6f34984..a80eb63 100644
86--- a/foo1.txt
87+++ b/foo1.txt
88@@ -2,3 +2,4 @@ base
89 foo 1
90 bar 1
91 baz 1
92+blah 1
93diff --git a/foo2.txt b/foo2.txt
94index 415c9f5..43168f2 100644
95--- a/foo2.txt
96+++ b/foo2.txt
97@@ -1,3 +1,4 @@
98 base
99 foo 2
100 bar 2
101+baz 2
102EOF
103test_expect_success 'Refresh --index' '
104 stg status &&
105 stg new p4 -m "refresh_index" &&
106 echo baz 1 >> foo1.txt &&
107 git add foo1.txt &&
108 echo blah 1 >> foo1.txt &&
109 echo baz 2 >> foo2.txt &&
110 stg refresh --index &&
111 stg patches foo1.txt > patches.txt &&
112 git diff HEAD^..HEAD > show.txt &&
113 stg diff > diff.txt &&
d9b2f20a
KH
114 test_cmp expected.txt patches.txt &&
115 test_cmp expected2.txt show.txt &&
116 test_cmp expected3.txt diff.txt &&
c3a72ae1
PO
117 stg new p5 -m "cleanup again" &&
118 stg refresh
119'
38baedf2 120
466bfe50
CM
121test_expect_success 'Refresh moved files' '
122 git mv foo1.txt foo1-new.txt &&
123 stg refresh
124'
125
38baedf2 126test_done