transport-helper: fix sync issue on crashes
[gitweb.git] / t / t5801-remote-helpers.sh
index 613f69a254bab23e1f09126b4a7f3dca8692deaa..aa3e223cde9cbc3c0e7575c834f1435f23620ada 100755 (executable)
@@ -94,6 +94,19 @@ test_expect_failure 'push new branch with old:new refspec' '
        compare_refs local HEAD server refs/heads/new-refspec
 '
 
+test_expect_success 'forced push' '
+       (cd local &&
+       git checkout -b force-test &&
+       echo content >> file &&
+       git commit -a -m eight &&
+       git push origin force-test &&
+       echo content >> file &&
+       git commit -a --amend -m eight-modified &&
+       git push --force origin force-test
+       ) &&
+       compare_refs local refs/heads/force-test server refs/heads/force-test
+'
+
 test_expect_success 'cloning without refspec' '
        GIT_REMOTE_TESTGIT_REFSPEC="" \
        git clone "testgit::${PWD}/server" local2 2>error &&
@@ -207,6 +220,20 @@ test_expect_success 'push update refs failure' '
        )
 '
 
+clean_mark () {
+       cut -f 2 -d ' ' "$1" |
+       git cat-file --batch-check |
+       grep commit |
+       sort >$(basename "$1")
+}
+
+cmp_marks () {
+       test_when_finished "rm -rf git.marks testgit.marks" &&
+       clean_mark ".git/testgit/$1/git.marks" &&
+       clean_mark ".git/testgit/$1/testgit.marks" &&
+       test_cmp git.marks testgit.marks
+}
+
 test_expect_success 'proper failure checks for fetching' '
        (GIT_REMOTE_TESTGIT_FAILURE=1 &&
        export GIT_REMOTE_TESTGIT_FAILURE &&
@@ -218,10 +245,12 @@ test_expect_success 'proper failure checks for fetching' '
 '
 
 test_expect_success 'proper failure checks for pushing' '
-       (GIT_REMOTE_TESTGIT_FAILURE=1 &&
-       export GIT_REMOTE_TESTGIT_FAILURE &&
-       cd local &&
-       test_must_fail git push --all
+       (cd local &&
+       git checkout -b crash master &&
+       echo crash >>file &&
+       git commit -a -m crash &&
+       test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all &&
+       cmp_marks origin
        )
 '