| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='Run "stg refresh -p"' |
| 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 | test_expect_success 'Initialize StGit stack' ' |
| 15 | stg init && |
| 16 | for i in 1 2; do |
| 17 | echo x > $i.txt && |
| 18 | git add $i.txt && |
| 19 | stg new p$i -m "Patch $i" && |
| 20 | stg refresh |
| 21 | done |
| 22 | ' |
| 23 | |
| 24 | touch expected0.txt |
| 25 | cat > expected1.txt <<EOF |
| 26 | A 1.txt |
| 27 | A new.txt |
| 28 | EOF |
| 29 | cat > expected2.txt <<EOF |
| 30 | A 2.txt |
| 31 | EOF |
| 32 | test_expect_failure 'Add new file to non-top patch' ' |
| 33 | stg status > status1.txt && |
| 34 | test_cmp expected0.txt status1.txt && |
| 35 | echo y > new.txt && |
| 36 | git add new.txt && |
| 37 | stg refresh -p p1 && |
| 38 | stg status > status2.txt && |
| 39 | test_cmp expected0.txt status2.txt && |
| 40 | stg files p1 > files1.txt && |
| 41 | test_cmp expected1.txt files1.txt && |
| 42 | stg files p2 > files2.txt && |
| 43 | test_cmp expected2.txt files2.txt |
| 44 | ' |
| 45 | |
| 46 | test_done |