]> git.ipfire.org Git - thirdparty/git.git/blobdiff - remote-curl.c
push: support signing pushes iff the server supports it
[thirdparty/git.git] / remote-curl.c
index 696a5ecf05d116bb24847079b5741fffe905a2f3..71fbbb694fc78471343f568a5e93b8013a7bb9cb 100644 (file)
@@ -11,6 +11,7 @@
 #include "argv-array.h"
 #include "credential.h"
 #include "sha1-array.h"
+#include "send-pack.h"
 
 static struct remote *remote;
 /* always ends with a trailing slash */
@@ -26,7 +27,8 @@ struct options {
                followtags : 1,
                dry_run : 1,
                thin : 1,
-               push_cert : 1;
+               /* One of the SEND_PACK_PUSH_CERT_* constants. */
+               push_cert : 2;
 };
 static struct options options;
 static struct string_list cas_options = STRING_LIST_INIT_DUP;
@@ -109,9 +111,11 @@ static int set_option(const char *name, const char *value)
                return 0;
        } else if (!strcmp(name, "pushcert")) {
                if (!strcmp(value, "true"))
-                       options.push_cert = 1;
+                       options.push_cert = SEND_PACK_PUSH_CERT_ALWAYS;
                else if (!strcmp(value, "false"))
-                       options.push_cert = 0;
+                       options.push_cert = SEND_PACK_PUSH_CERT_NEVER;
+               else if (!strcmp(value, "if-asked"))
+                       options.push_cert = SEND_PACK_PUSH_CERT_IF_ASKED;
                else
                        return -1;
                return 0;
@@ -880,8 +884,10 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
                argv_array_push(&args, "--thin");
        if (options.dry_run)
                argv_array_push(&args, "--dry-run");
-       if (options.push_cert)
-               argv_array_push(&args, "--signed");
+       if (options.push_cert == SEND_PACK_PUSH_CERT_ALWAYS)
+               argv_array_push(&args, "--signed=yes");
+       else if (options.push_cert == SEND_PACK_PUSH_CERT_IF_ASKED)
+               argv_array_push(&args, "--signed=if-asked");
        if (options.verbosity == 0)
                argv_array_push(&args, "--quiet");
        else if (options.verbosity > 1)
@@ -961,6 +967,8 @@ int main(int argc, const char **argv)
        struct strbuf buf = STRBUF_INIT;
        int nongit;
 
+       git_setup_gettext();
+
        git_extract_argv0_path(argv[0]);
        setup_git_directory_gently(&nongit);
        if (argc < 2) {