t3030: merge-recursive backend test.
[gitweb.git] / builtin-push.c
index c45649e26cf5284323aa80a5fe73b5842346eb14..cb78401c946eac9019c2e4e953c3b87ef9e214f3 100644 (file)
@@ -32,7 +32,7 @@ static int expand_one_ref(const char *ref, const unsigned char *sha1, int flag,
        /* Ignore the "refs/" at the beginning of the refname */
        ref += 5;
 
-       if (!strncmp(ref, "tags/", 5))
+       if (!prefixcmp(ref, "tags/"))
                add_refspec(xstrdup(ref));
        return 0;
 }
@@ -149,10 +149,10 @@ static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])
                int is_refspec;
                char *s, *p;
 
-               if (!strncmp("URL:", buffer, 4)) {
+               if (!prefixcmp(buffer, "URL:")) {
                        is_refspec = 0;
                        s = buffer + 4;
-               } else if (!strncmp("Push:", buffer, 5)) {
+               } else if (!prefixcmp(buffer, "Push:")) {
                        is_refspec = 1;
                        s = buffer + 5;
                } else
@@ -195,7 +195,7 @@ static int config_get_receivepack;
 
 static int get_remote_config(const char* key, const char* value)
 {
-       if (!strncmp(key, "remote.", 7) &&
+       if (!prefixcmp(key, "remote.") &&
            !strncmp(key + 7, config_repo, config_repo_len)) {
                if (!strcmp(key + 7 + config_repo_len, ".url")) {
                        if (config_current_uri < MAX_URI)
@@ -297,7 +297,7 @@ static int read_config(const char *repo, const char *uri[MAX_URI])
 static int do_push(const char *repo)
 {
        const char *uri[MAX_URI];
-       int i, n;
+       int i, n, errs;
        int common_argc;
        const char **argv;
        int argc;
@@ -317,16 +317,17 @@ static int do_push(const char *repo)
                argv[argc++] = receivepack;
        common_argc = argc;
 
+       errs = 0;
        for (i = 0; i < n; i++) {
                int err;
                int dest_argc = common_argc;
                int dest_refspec_nr = refspec_nr;
                const char **dest_refspec = refspec;
                const char *dest = uri[i];
-               const char *sender = "git-send-pack";
-               if (!strncmp(dest, "http://", 7) ||
-                   !strncmp(dest, "https://", 8))
-                       sender = "git-http-push";
+               const char *sender = "send-pack";
+               if (!prefixcmp(dest, "http://") ||
+                   !prefixcmp(dest, "https://"))
+                       sender = "http-push";
                else if (thin)
                        argv[dest_argc++] = "--thin";
                argv[0] = sender;
@@ -336,24 +337,26 @@ static int do_push(const char *repo)
                argv[dest_argc] = NULL;
                if (verbose)
                        fprintf(stderr, "Pushing to %s\n", dest);
-               err = run_command_v(argv);
+               err = run_command_v_opt(argv, RUN_GIT_CMD);
                if (!err)
                        continue;
+
+               error("failed to push to '%s'", uri[i]);
                switch (err) {
                case -ERR_RUN_COMMAND_FORK:
-                       die("unable to fork for %s", sender);
+                       error("unable to fork for %s", sender);
                case -ERR_RUN_COMMAND_EXEC:
-                       die("unable to exec %s", sender);
+                       error("unable to exec %s", sender);
+                       break;
                case -ERR_RUN_COMMAND_WAITPID:
                case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
                case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
                case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
-                       die("%s died with strange error", sender);
-               default:
-                       return -err;
+                       error("%s died with strange error", sender);
                }
+               errs++;
        }
-       return 0;
+       return !!errs;
 }
 
 int cmd_push(int argc, const char **argv, const char *prefix)
@@ -373,7 +376,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
                        verbose=1;
                        continue;
                }
-               if (!strncmp(arg, "--repo=", 7)) {
+               if (!prefixcmp(arg, "--repo=")) {
                        repo = arg+7;
                        continue;
                }
@@ -397,11 +400,11 @@ int cmd_push(int argc, const char **argv, const char *prefix)
                        thin = 0;
                        continue;
                }
-               if (!strncmp(arg, "--receive-pack=", 15)) {
+               if (!prefixcmp(arg, "--receive-pack=")) {
                        receivepack = arg;
                        continue;
                }
-               if (!strncmp(arg, "--exec=", 7)) {
+               if (!prefixcmp(arg, "--exec=")) {
                        receivepack = arg;
                        continue;
                }