From: Karl Hasselström Date: Thu, 20 Mar 2008 23:12:11 +0000 (+0000) Subject: New test: conflicting push in dirty worktree X-Git-Tag: v0.15-rc1~265 X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/commitdiff_plain/923309140a6f091df9ed7120d7c818586c980c86 New test: conflicting push in dirty worktree When the result of a conflicting push can't be represented in the worktree because the worktree is dirty, the push should be aborted. Similarly, the push should be aborted if we have to do the merge in the worktree, but can't because the worktree is dirty. Add a new test that tests for this. It currently fails, in a bad way: the contents of the pushed patch is lost. (The test uses goto instead of push, because push doesn't use the new infrastructure yet. And old-infrastructure commands never have this bug, because they refuse to run with a dirty worktree.) This bug was found by Erik Sandberg , who also came up with the minimal test case that I turned into this new test. Signed-off-by: Karl Hasselström --- diff --git a/t/t3000-dirty-merge.sh b/t/t3000-dirty-merge.sh new file mode 100755 index 0000000..dd81c9e --- /dev/null +++ b/t/t3000-dirty-merge.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +test_description='Try a push that requires merging a file that is dirty' + +. ./test-lib.sh + +test_expect_success 'Initialize StGit stack with two patches' ' + stg init && + touch a && + git add a && + git commit -m a && + echo 1 > a && + git commit -a -m p1 && + echo 2 > a && + git commit -a -m p2 && + stg uncommit -n 2 +' + +test_expect_success 'Pop one patch and update the other' ' + stg goto p1 && + echo 3 > a && + stg refresh +' + +test_expect_failure 'Push with dirty worktree' ' + echo 4 > a && + [ "$(echo $(stg applied))" = "p1" ] && + [ "$(echo $(stg unapplied))" = "p2" ] && + ! stg goto p2 && + [ "$(echo $(stg applied))" = "p1" ] && + [ "$(echo $(stg unapplied))" = "p2" ] && + [ "$(echo $(cat a))" = "4" ] +' + +test_done