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