Disable patchlog test for "stg new"
[stgit/dwhite.git] / t / t2700-refresh.sh
blob3759d0e98e9a2c1a9c0bf56b908cfb66cc9d5089
1 #!/bin/sh
3 test_description='Run "stg refresh"'
5 . ./test-lib.sh
7 test_expect_success 'Initialize StGit stack' '
8 stg init &&
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" &&
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
26 cat > expected.txt <<EOF
29 EOF
30 test_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 &&
36 test_cmp expected.txt patches.txt
39 cat > expected.txt <<EOF
42 EOF
43 test_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 &&
50 test_cmp expected.txt patches.txt
53 cat > expected.txt <<EOF
56 EOF
57 test_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 &&
64 test_cmp expected.txt patches.txt
67 cat > expected.txt <<EOF
71 EOF
72 cat > expected2.txt <<EOF
73 diff --git a/foo1.txt b/foo1.txt
74 index 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
82 EOF
83 cat > expected3.txt <<EOF
84 diff --git a/foo1.txt b/foo1.txt
85 index 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
93 diff --git a/foo2.txt b/foo2.txt
94 index 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
103 test_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 &&
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" &&
118 stg refresh
120 test_done