diff options
-rwxr-xr-x | t/t5801-remote-helpers.sh | 20 | ||||
-rw-r--r-- | transport-helper.c | 13 |
2 files changed, 30 insertions, 3 deletions
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh index 25fd2e7f46..aa3e223cde 100755 --- a/t/t5801-remote-helpers.sh +++ b/t/t5801-remote-helpers.sh @@ -220,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 && @@ -232,7 +246,11 @@ test_expect_success 'proper failure checks for fetching' ' test_expect_success 'proper failure checks for pushing' ' (cd local && - test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all + 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 ) ' diff --git a/transport-helper.c b/transport-helper.c index c890db620b..b468e4f88e 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -435,7 +435,7 @@ static int get_exporter(struct transport *transport, fastexport->argv[argc++] = data->signed_tags ? "--signed-tags=verbatim" : "--signed-tags=warn-strip"; if (data->export_marks) { - strbuf_addf(&tmp, "--export-marks=%s", data->export_marks); + strbuf_addf(&tmp, "--export-marks=%s.tmp", data->export_marks); fastexport->argv[argc++] = strbuf_detach(&tmp, NULL); } if (data->import_marks) { @@ -911,7 +911,16 @@ static int push_refs_with_export(struct transport *transport, if (finish_command(&exporter)) die("Error while running fast-export"); - return push_update_refs_status(data, remote_refs, flags); + if (push_update_refs_status(data, remote_refs, flags)) + return 1; + + if (data->export_marks) { + strbuf_addf(&buf, "%s.tmp", data->export_marks); + rename(buf.buf, data->export_marks); + strbuf_release(&buf); + } + + return 0; } static int push_refs(struct transport *transport, |