commit ce2b05c76c2655b619f516e32f44a54d0c8741db from: Stefan Sperling date: Sat Aug 10 14:12:32 2019 UTC test reverting the first hunk only with revert -p commit - d473b4e492e89856bc4fea9aaea739bddd5c5e4b commit + ce2b05c76c2655b619f516e32f44a54d0c8741db blob - 4ef46ac70695dfee3f56957de47bc0f1a7b14a23 blob + e2eeccfccbcc07ff559c411508ff3c8e31f59918 --- regress/cmdline/revert.sh +++ regress/cmdline/revert.sh @@ -415,6 +415,107 @@ EOF return 1 fi + # revert first hunk + printf "y\nn\nn\n" > $testroot/patchscript + (cd $testroot/wt && got revert -F $testroot/patchscript -p \ + numbers > $testroot/stdout) + ret="$?" + if [ "$ret" != "0" ]; then + echo "got revert command failed unexpectedly" >&2 + test_done "$testroot" "1" + return 1 + fi + cat > $testroot/stdout.expected < $testroot/stdout) + echo "M numbers" > $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret="$?" + if [ "$ret" != "0" ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected + echo -n 'blob - ' >> $testroot/stdout.expected + got tree -r $testroot/repo -i -c $commit_id \ + | grep 'numbers$' | cut -d' ' -f 1 \ + >> $testroot/stdout.expected + echo 'file + numbers' >> $testroot/stdout.expected + cat >> $testroot/stdout.expected < $testroot/stdout) + cmp -s $testroot/stdout.expected $testroot/stdout + ret="$?" + if [ "$ret" != "0" ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + # put first hunk back + sed -i -e 's/^2$/a/' $testroot/wt/numbers + # revert middle hunk printf "n\ny\nn\n" > $testroot/patchscript (cd $testroot/wt && got revert -F $testroot/patchscript -p \