Merge branch 'tz/credential-netrc'
[gitweb.git] / builtin / send-pack.c
index 152c4ea092a44ff9e70e293ddeecb4ad7105e25d..4482f16efb66c7fc06c7446a2e992840cc83f798 100644 (file)
@@ -5,6 +5,7 @@
 #include "sideband.h"
 #include "run-command.h"
 #include "remote.h"
+#include "connect.h"
 #include "send-pack.h"
 #include "quote.h"
 #include "transport.h"
@@ -54,6 +55,11 @@ static void print_helper_status(struct ref *ref)
                        msg = "needs force";
                        break;
 
+               case REF_STATUS_REJECT_STALE:
+                       res = "error";
+                       msg = "stale info";
+                       break;
+
                case REF_STATUS_REJECT_ALREADY_EXISTS:
                        res = "error";
                        msg = "already exists";
@@ -102,6 +108,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
        int flags;
        unsigned int reject_reasons;
        int progress = -1;
+       struct push_cas_option cas = {0};
 
        argv++;
        for (i = 1; i < argc; i++, argv++) {
@@ -164,6 +171,22 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
                                helper_status = 1;
                                continue;
                        }
+                       if (!strcmp(arg, "--" CAS_OPT_NAME)) {
+                               if (parse_push_cas_option(&cas, NULL, 0) < 0)
+                                       exit(1);
+                               continue;
+                       }
+                       if (!strcmp(arg, "--no-" CAS_OPT_NAME)) {
+                               if (parse_push_cas_option(&cas, NULL, 1) < 0)
+                                       exit(1);
+                               continue;
+                       }
+                       if (!prefixcmp(arg, "--" CAS_OPT_NAME "=")) {
+                               if (parse_push_cas_option(&cas,
+                                                         strchr(arg, '=') + 1, 0) < 0)
+                                       exit(1);
+                               continue;
+                       }
                        usage(send_pack_usage);
                }
                if (!dest) {
@@ -224,6 +247,9 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
        if (match_push_refs(local_refs, &remote_refs, nr_refspecs, refspecs, flags))
                return -1;
 
+       if (!is_empty_cas(&cas))
+               apply_push_cas(&cas, remote, remote_refs);
+
        set_ref_status_for_push(remote_refs, args.send_mirror,
                args.force_update);