mergetool: don't require a work tree for --tool-help
[gitweb.git] / transport-helper.c
index c890db620bce7ea553e30a74e6f7a6b9d7226c13..b9ba0416b24fb2d53b410b3b97424e9efd552b43 100644 (file)
@@ -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,
@@ -1017,7 +1026,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
 
 int transport_helper_init(struct transport *transport, const char *name)
 {
-       struct helper_data *data = xcalloc(sizeof(*data), 1);
+       struct helper_data *data = xcalloc(1, sizeof(*data));
        data->name = name;
 
        if (getenv("GIT_TRANSPORT_HELPER_DEBUG"))