t5533: test "push --force-with-lease"
[gitweb.git] / transport-helper.c
index 6cd0be90e0a4e6d377004d8dbf37ae9f254640f4..95d22f8d96d556a40639da2a38043b1d1b5bf380 100644 (file)
@@ -26,6 +26,7 @@ struct helper_data {
                option : 1,
                push : 1,
                connect : 1,
+               signed_tags : 1,
                no_disconnect_req : 1;
        char *export_marks;
        char *import_marks;
@@ -55,7 +56,7 @@ static int recvline_fh(FILE *helper, struct strbuf *buffer, const char *name)
        if (strbuf_getline(buffer, helper, '\n') == EOF) {
                if (debug)
                        fprintf(stderr, "Debug: Remote helper quit.\n");
-               die("Reading from helper 'git-remote-%s' failed", name);
+               exit(128);
        }
 
        if (debug)
@@ -192,6 +193,8 @@ static struct child_process *get_helper(struct transport *transport)
                        refspecs[refspec_nr++] = xstrdup(capname + strlen("refspec "));
                } else if (!strcmp(capname, "connect")) {
                        data->connect = 1;
+               } else if (!strcmp(capname, "signed-tags")) {
+                       data->signed_tags = 1;
                } else if (!prefixcmp(capname, "export-marks ")) {
                        struct strbuf arg = STRBUF_INIT;
                        strbuf_addstr(&arg, "--export-marks=");
@@ -212,9 +215,8 @@ static struct child_process *get_helper(struct transport *transport)
                int i;
                data->refspec_nr = refspec_nr;
                data->refspecs = parse_fetch_refspec(refspec_nr, refspecs);
-               for (i = 0; i < refspec_nr; i++) {
+               for (i = 0; i < refspec_nr; i++)
                        free((char *)refspecs[i]);
-               }
                free(refspecs);
        } else if (data->import || data->bidi_import || data->export) {
                warning("This remote helper should implement refspec capability.");
@@ -413,9 +415,11 @@ static int get_exporter(struct transport *transport,
        /* we need to duplicate helper->in because we want to use it after
         * fastexport is done with it. */
        fastexport->out = dup(helper->in);
-       fastexport->argv = xcalloc(5 + revlist_args->nr, sizeof(*fastexport->argv));
+       fastexport->argv = xcalloc(6 + revlist_args->nr, sizeof(*fastexport->argv));
        fastexport->argv[argc++] = "fast-export";
        fastexport->argv[argc++] = "--use-done-feature";
+       fastexport->argv[argc++] = data->signed_tags ?
+               "--signed-tags=verbatim" : "--signed-tags=warn-strip";
        if (data->export_marks)
                fastexport->argv[argc++] = data->export_marks;
        if (data->import_marks)
@@ -679,6 +683,11 @@ static int push_update_ref_status(struct strbuf *buf,
                        free(msg);
                        msg = NULL;
                }
+               else if (!strcmp(msg, "stale info")) {
+                       status = REF_STATUS_REJECT_STALE;
+                       free(msg);
+                       msg = NULL;
+               }
        }
 
        if (*ref)
@@ -752,6 +761,7 @@ static int push_refs_with_push(struct transport *transport,
                /* Check for statuses set by set_ref_status_for_push() */
                switch (ref->status) {
                case REF_STATUS_REJECT_NONFASTFORWARD:
+               case REF_STATUS_REJECT_STALE:
                case REF_STATUS_REJECT_ALREADY_EXISTS:
                case REF_STATUS_UPTODATE:
                        continue;
@@ -805,6 +815,11 @@ static int push_refs_with_export(struct transport *transport,
        if (!data->refspecs)
                die("remote-helper doesn't support push; refspec needed");
 
+       if (flags & TRANSPORT_PUSH_DRY_RUN) {
+               if (set_helper_option(transport, "dry-run", "true") != 0)
+                       die("helper %s does not support dry-run", data->name);
+       }
+
        helper = get_helper(transport);
 
        write_constant(helper->in, "export\n");
@@ -826,8 +841,14 @@ static int push_refs_with_export(struct transport *transport,
                }
                free(private);
 
-               if (ref->peer_ref)
+               if (ref->deletion)
+                       die("remote-helpers do not support ref deletion");
+
+               if (ref->peer_ref) {
+                       if (strcmp(ref->peer_ref->name, ref->name))
+                               die("remote-helpers do not support old:new syntax");
                        string_list_append(&revlist_args, ref->peer_ref->name);
+               }
        }
 
        if (get_exporter(transport, &exporter, &revlist_args))
@@ -1008,7 +1029,7 @@ struct unidirectional_transfer {
        int src_is_sock;
        /* Is destination socket? */
        int dest_is_sock;
-       /* Transfer state (TRANSFERING/FLUSHING/FINISHED) */
+       /* Transfer state (TRANSFERRING/FLUSHING/FINISHED) */
        int state;
        /* Buffer. */
        char buf[BUFFERSIZE];