Skip to content

Commit cd16c59

Browse files
johnkeepinggitster
authored andcommitted
fast-export: add --signed-tags=warn-strip mode
This issues a warning while stripping signatures from signed tags, which allows us to use it as default behaviour for remote helpers which cannot specify how to handle signed tags. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 85e7e81 commit cd16c59

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

Documentation/git-fast-export.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@ OPTIONS
2727
Insert 'progress' statements every <n> objects, to be shown by
2828
'git fast-import' during import.
2929

30-
--signed-tags=(verbatim|warn|strip|abort)::
30+
--signed-tags=(verbatim|warn|warn-strip|strip|abort)::
3131
Specify how to handle signed tags. Since any transformation
3232
after the export can change the tag names (which can also happen
3333
when excluding revisions) the signatures will not match.
3434
+
3535
When asking to 'abort' (which is the default), this program will die
36-
when encountering a signed tag. With 'strip', the tags will be made
37-
unsigned, with 'verbatim', they will be silently exported
38-
and with 'warn', they will be exported, but you will see a warning.
36+
when encountering a signed tag. With 'strip', the tags will silently
37+
be made unsigned, with 'warn-strip' they will be made unsigned but a
38+
warning will be displayed, with 'verbatim', they will be silently
39+
exported and with 'warn', they will be exported, but you will see a
40+
warning.
3941

4042
--tag-of-filtered-object=(abort|drop|rewrite)::
4143
Specify how to handle tags whose tagged object is filtered out.

builtin/fast-export.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static const char *fast_export_usage[] = {
2424
};
2525

2626
static int progress;
27-
static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT;
27+
static enum { ABORT, VERBATIM, WARN, WARN_STRIP, STRIP } signed_tag_mode = ABORT;
2828
static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ERROR;
2929
static int fake_missing_tagger;
3030
static int use_done_feature;
@@ -40,6 +40,8 @@ static int parse_opt_signed_tag_mode(const struct option *opt,
4040
signed_tag_mode = VERBATIM;
4141
else if (!strcmp(arg, "warn"))
4242
signed_tag_mode = WARN;
43+
else if (!strcmp(arg, "warn-strip"))
44+
signed_tag_mode = WARN_STRIP;
4345
else if (!strcmp(arg, "strip"))
4446
signed_tag_mode = STRIP;
4547
else
@@ -428,6 +430,10 @@ static void handle_tag(const char *name, struct tag *tag)
428430
/* fallthru */
429431
case VERBATIM:
430432
break;
433+
case WARN_STRIP:
434+
warning ("Stripping signature from tag %s",
435+
sha1_to_hex(tag->object.sha1));
436+
/* fallthru */
431437
case STRIP:
432438
message_size = signature + 1 - message;
433439
break;

t/t9350-fast-export.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ test_expect_success 'signed-tags=strip' '
146146
147147
'
148148

149+
test_expect_success 'signed-tags=warn-strip' '
150+
git fast-export --signed-tags=warn-strip sign-your-name >output 2>err &&
151+
! grep PGP output &&
152+
test -s err
153+
'
154+
149155
test_expect_success 'setup submodule' '
150156
151157
git checkout -f master &&

0 commit comments

Comments
 (0)