rev-list: fix --pretty=oneline with empty message
[gitweb.git] / transport-helper.c
index 50b3bac0c45252855505f4ce019a8cec53164fad..f822972020136b0fa04a95d7fcf26df40c81cfe6 100644 (file)
@@ -102,6 +102,7 @@ static struct child_process *get_helper(struct transport *transport)
        int refspec_nr = 0;
        int refspec_alloc = 0;
        int duped;
+       int code;
 
        if (data->helper)
                return data->helper;
@@ -111,13 +112,18 @@ static struct child_process *get_helper(struct transport *transport)
        helper->out = -1;
        helper->err = 0;
        helper->argv = xcalloc(4, sizeof(*helper->argv));
-       strbuf_addf(&buf, "remote-%s", data->name);
+       strbuf_addf(&buf, "git-remote-%s", data->name);
        helper->argv[0] = strbuf_detach(&buf, NULL);
        helper->argv[1] = transport->remote->name;
        helper->argv[2] = remove_ext_force(transport->url);
-       helper->git_cmd = 1;
-       if (start_command(helper))
-               die("Unable to run helper: git %s", helper->argv[0]);
+       helper->git_cmd = 0;
+       helper->silent_exec_failure = 1;
+       code = start_command(helper);
+       if (code < 0 && errno == ENOENT)
+               die("Unable to find remote helper for '%s'", data->name);
+       else if (code != 0)
+               exit(code);
+
        data->helper = helper;
        data->no_disconnect_req = 0;
 
@@ -165,7 +171,7 @@ static struct child_process *get_helper(struct transport *transport)
                } else if (!strcmp(capname, "connect")) {
                        data->connect = 1;
                } else if (mandatory) {
-                       die("Unknown madatory capability %s. This remote "
+                       die("Unknown mandatory capability %s. This remote "
                            "helper probably needs newer version of Git.\n",
                            capname);
                }
@@ -273,7 +279,7 @@ static void standard_options(struct transport *t)
        char buf[16];
        int n;
        int v = t->verbose;
-       int no_progress = v < 0 || (!t->progress && !isatty(1));
+       int no_progress = v < 0 || (!t->progress && !isatty(2));
 
        set_helper_option(t, "progress", !no_progress ? "true" : "false");
 
@@ -467,6 +473,24 @@ static int process_connect(struct transport *transport,
        return process_connect_service(transport, name, exec);
 }
 
+static int connect_helper(struct transport *transport, const char *name,
+                  const char *exec, int fd[2])
+{
+       struct helper_data *data = transport->data;
+
+       /* Get_helper so connect is inited. */
+       get_helper(transport);
+       if (!data->connect)
+               die("Operation not supported by protocol.");
+
+       if (!process_connect_service(transport, name, exec))
+               die("Can't connect to subservice %s.", name);
+
+       fd[0] = data->helper->out;
+       fd[1] = data->helper->in;
+       return 0;
+}
+
 static int fetch(struct transport *transport,
                 int nr_heads, struct ref **to_fetch)
 {
@@ -510,24 +534,27 @@ static int push_refs(struct transport *transport,
                return transport->push_refs(transport, remote_refs, flags);
        }
 
-       if (!remote_refs)
+       if (!remote_refs) {
+               fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
+                       "Perhaps you should specify a branch such as 'master'.\n");
                return 0;
+       }
 
        helper = get_helper(transport);
        if (!data->push)
                return 1;
 
        for (ref = remote_refs; ref; ref = ref->next) {
-               if (ref->peer_ref)
-                       hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
-               else if (!mirror)
+               if (!ref->peer_ref && !mirror)
                        continue;
 
-               ref->deletion = is_null_sha1(ref->new_sha1);
-               if (!ref->deletion &&
-                       !hashcmp(ref->old_sha1, ref->new_sha1)) {
-                       ref->status = REF_STATUS_UPTODATE;
+               /* Check for statuses set by set_ref_status_for_push() */
+               switch (ref->status) {
+               case REF_STATUS_REJECT_NONFASTFORWARD:
+               case REF_STATUS_UPTODATE:
                        continue;
+               default:
+                       ; /* do nothing */
                }
 
                if (force_all)
@@ -616,6 +643,15 @@ static int push_refs(struct transport *transport,
                        continue;
                }
 
+               if (ref->status != REF_STATUS_NONE) {
+                       /*
+                        * Earlier, the ref was marked not to be pushed, so ignore the ref
+                        * status reported by the remote helper if the latter is 'no match'.
+                        */
+                       if (status == REF_STATUS_NONE)
+                               continue;
+               }
+
                ref->status = status;
                ref->remote_status = msg;
        }
@@ -711,6 +747,7 @@ int transport_helper_init(struct transport *transport, const char *name)
        transport->fetch = fetch;
        transport->push_refs = push_refs;
        transport->disconnect = release_helper;
+       transport->connect = connect_helper;
        transport->smart_options = &(data->transport_options);
        return 0;
 }