Merge branch 'jk/remote-helper-with-signed-tags'
authorJunio C Hamano <gitster@pobox.com>
Wed, 24 Apr 2013 23:30:50 +0000 (16:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Apr 2013 23:30:50 +0000 (16:30 -0700)
Allows remote-helpers to declare they can handle signed tags, and
issue a warning when using those that don't.

* jk/remote-helper-with-signed-tags:
transport-helper: add 'signed-tags' capability
transport-helper: pass --signed-tags=warn-strip to fast-export
fast-export: add --signed-tags=warn-strip mode

Documentation/git-fast-export.txt
Documentation/gitremote-helpers.txt
builtin/fast-export.c
git-remote-testgit
t/t5801-remote-helpers.sh
t/t9350-fast-export.sh
transport-helper.c
index feab7a3e4ecb56aa17c32bd555e907a51001ef1f..03fc8c39d8607677533b72c39b11e14151ac5b60 100644 (file)
@@ -27,15 +27,17 @@ OPTIONS
        Insert 'progress' statements every <n> objects, to be shown by
        'git fast-import' during import.
 
---signed-tags=(verbatim|warn|strip|abort)::
+--signed-tags=(verbatim|warn|warn-strip|strip|abort)::
        Specify how to handle signed tags.  Since any transformation
        after the export can change the tag names (which can also happen
        when excluding revisions) the signatures will not match.
 +
 When asking to 'abort' (which is the default), this program will die
-when encountering a signed tag.  With 'strip', the tags will be made
-unsigned, with 'verbatim', they will be silently exported
-and with 'warn', they will be exported, but you will see a warning.
+when encountering a signed tag.  With 'strip', the tags will silently
+be made unsigned, with 'warn-strip' they will be made unsigned but a
+warning will be displayed, with 'verbatim', they will be silently
+exported and with 'warn', they will be exported, but you will see a
+warning.
 
 --tag-of-filtered-object=(abort|drop|rewrite)::
        Specify how to handle tags whose tagged object is filtered out.
index f506031ae49070e216e71914d8ef241da58430e1..da746419b355a4b5d49b23ed51e3d4aa89d8c2c1 100644 (file)
@@ -202,6 +202,10 @@ capability then it should advertise `refspec *:*`.
        marks specified in <file> before processing any input. For details,
        read up on '--import-marks=<file>' in linkgit:git-fast-export[1].
 
+'signed-tags'::
+       This modifies the 'export' capability, instructing Git to pass
+       '--signed-tags=verbatim' to linkgit:git-fast-export[1].  In the
+       absence of this capability, Git will use '--signed-tags=warn-strip'.
 
 
 
index 725c0a7dca70ae8cbb31f571e0284f5c31a61cff..d60d675f6f5f1a2df50bdd3a6ba076e8c0ddd1f2 100644 (file)
@@ -24,7 +24,7 @@ static const char *fast_export_usage[] = {
 };
 
 static int progress;
-static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT;
+static enum { ABORT, VERBATIM, WARN, WARN_STRIP, STRIP } signed_tag_mode = ABORT;
 static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ERROR;
 static int fake_missing_tagger;
 static int use_done_feature;
@@ -40,6 +40,8 @@ static int parse_opt_signed_tag_mode(const struct option *opt,
                signed_tag_mode = VERBATIM;
        else if (!strcmp(arg, "warn"))
                signed_tag_mode = WARN;
+       else if (!strcmp(arg, "warn-strip"))
+               signed_tag_mode = WARN_STRIP;
        else if (!strcmp(arg, "strip"))
                signed_tag_mode = STRIP;
        else
@@ -428,6 +430,10 @@ static void handle_tag(const char *name, struct tag *tag)
                                /* fallthru */
                        case VERBATIM:
                                break;
+                       case WARN_STRIP:
+                               warning ("Stripping signature from tag %s",
+                                        sha1_to_hex(tag->object.sha1));
+                               /* fallthru */
                        case STRIP:
                                message_size = signature + 1 - message;
                                break;
index b395c8de59c33768f1a957248447d162bda8ef94..e7ed3a33e6d7180e65f06a882342fa2d7efb4d03 100755 (executable)
@@ -38,6 +38,7 @@ do
                        echo "*import-marks $gitmarks"
                        echo "*export-marks $gitmarks"
                fi
+               test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
                echo
                ;;
        list)
index f387027c05cf502c6892c7694598bef34376be92..69212cdde14c012261eabc4ac9b2e5956213f8d5 100755 (executable)
@@ -6,6 +6,7 @@
 test_description='Test remote-helper import and export commands'
 
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-gpg.sh
 
 if ! type "${BASH-bash}" >/dev/null 2>&1; then
        skip_all='skipping remote-testgit tests, bash not available'
@@ -166,4 +167,23 @@ test_expect_success 'push ref with existing object' '
        compare_refs local dup server dup
 '
 
+test_expect_success GPG 'push signed tag' '
+       (cd local &&
+       git checkout master &&
+       git tag -s -m signed-tag signed-tag &&
+       git push origin signed-tag
+       ) &&
+       compare_refs local signed-tag^{} server signed-tag^{} &&
+       test_must_fail compare_refs local signed-tag server signed-tag
+'
+
+test_expect_success GPG 'push signed tag with signed-tags capability' '
+       (cd local &&
+       git checkout master &&
+       git tag -s -m signed-tag signed-tag-2 &&
+       GIT_REMOTE_TESTGIT_SIGNED_TAGS=1 git push origin signed-tag-2
+       ) &&
+       compare_refs local signed-tag-2 server signed-tag-2
+'
+
 test_done
index 9320b4f94c25bf376a004c2c0d4451c0fd96f969..2471bc6777df58c222a96d4fc6e77d77e9e38703 100755 (executable)
@@ -146,6 +146,12 @@ test_expect_success 'signed-tags=strip' '
 
 '
 
+test_expect_success 'signed-tags=warn-strip' '
+       git fast-export --signed-tags=warn-strip sign-your-name >output 2>err &&
+       ! grep PGP output &&
+       test -s err
+'
+
 test_expect_success 'setup submodule' '
 
        git checkout -f master &&
index dcd8d97411dd15e01ba1480a44b2a998043b424a..5f8d075ed8c18b198e956bf10d6647598f565597 100644 (file)
@@ -25,6 +25,7 @@ struct helper_data {
                option : 1,
                push : 1,
                connect : 1,
+               signed_tags : 1,
                no_disconnect_req : 1;
        char *export_marks;
        char *import_marks;
@@ -191,6 +192,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=");
@@ -410,9 +413,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)