3 test_description
='Run "stg refresh"'
7 test_expect_success
'Initialize StGit stack' '
9 echo expected*.txt >> .git/info/exclude &&
10 echo patches.txt >> .git/info/exclude &&
11 echo show.txt >> .git/info/exclude &&
12 echo diff.txt >> .git/info/exclude &&
13 stg new p0 -m "base" &&
15 echo base >> foo$i.txt &&
20 stg new p$i -m "foo $i" &&
21 echo "foo $i" >> foo$i.txt &&
26 cat > expected.txt
<<EOF
30 test_expect_success
'Refresh top patch' '
31 echo bar 3 >> foo3.txt &&
34 test -z "$(stg status)" &&
35 stg patches foo3.txt > patches.txt &&
36 test_cmp expected.txt patches.txt
39 cat > expected.txt
<<EOF
43 test_expect_success
'Refresh middle patch' '
45 echo bar 2 >> foo2.txt &&
48 test -z "$(stg status)" &&
49 stg patches foo2.txt > patches.txt &&
50 test_cmp expected.txt patches.txt
53 cat > expected.txt
<<EOF
57 test_expect_success
'Refresh bottom patch' '
59 echo bar 1 >> foo1.txt &&
62 test -z "$(stg status)" &&
63 stg patches foo1.txt > patches.txt &&
64 test_cmp expected.txt patches.txt
67 cat > expected.txt
<<EOF
72 cat > expected2.txt
<<EOF
73 diff --git a/foo1.txt b/foo1.txt
74 index 728535d..6f34984 100644
83 cat > expected3.txt
<<EOF
84 diff --git a/foo1.txt b/foo1.txt
85 index 6f34984..a80eb63 100644
93 diff --git a/foo2.txt b/foo2.txt
94 index 415c9f5..43168f2 100644
103 test_expect_success
'Refresh --index' '
105 stg new p4 -m "refresh_index" &&
106 echo baz 1 >> 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 &&
114 test_cmp expected.txt patches.txt &&
115 test_cmp expected2.txt show.txt &&
116 test_cmp expected3.txt diff.txt &&
117 stg new p5 -m "cleanup again" &&
121 test_expect_success
'Refresh moved files' '
122 git mv foo1.txt foo1-new.txt &&