Skip to content

Commit 6d35cc4

Browse files
jltoblergitster
authored andcommitted
fast-export: check for unsupported signing modes earlier
The '--signed-{commits,tags}' options for git-fast-export(1) support only a subset of the modes accepted by git-fast-import(1). Unsupported modes such as 'strip-if-invalid' and 'sign-if-invalid' are accepted during option parsing, but cause the command to die later when a signed object is encountered. Instead, reject unsupported signing modes immediately after parsing the option. This treats them the same as other unknown modes and avoids deferring the error until object processing. This also removes duplicated checks in commit/tag handling code. Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent ce74208 commit 6d35cc4

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

builtin/fast-export.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static int parse_opt_sign_mode(const struct option *opt,
6464
if (unset)
6565
return 0;
6666

67-
if (parse_sign_mode(arg, val, NULL))
67+
if (parse_sign_mode(arg, val, NULL) || (*val == SIGN_STRIP_IF_INVALID) ||
68+
(*val == SIGN_SIGN_IF_INVALID))
6869
return error(_("unknown %s mode: %s"), opt->long_name, arg);
6970

7071
return 0;
@@ -822,12 +823,6 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
822823
die(_("encountered signed commit %s; use "
823824
"--signed-commits=<mode> to handle it"),
824825
oid_to_hex(&commit->object.oid));
825-
case SIGN_STRIP_IF_INVALID:
826-
die(_("'strip-if-invalid' is not a valid mode for "
827-
"git fast-export with --signed-commits=<mode>"));
828-
case SIGN_SIGN_IF_INVALID:
829-
die(_("'sign-if-invalid' is not a valid mode for "
830-
"git fast-export with --signed-commits=<mode>"));
831826
default:
832827
BUG("invalid signed_commit_mode value %d", signed_commit_mode);
833828
}
@@ -970,12 +965,6 @@ static void handle_tag(const char *name, struct tag *tag)
970965
die(_("encountered signed tag %s; use "
971966
"--signed-tags=<mode> to handle it"),
972967
oid_to_hex(&tag->object.oid));
973-
case SIGN_STRIP_IF_INVALID:
974-
die(_("'strip-if-invalid' is not a valid mode for "
975-
"git fast-export with --signed-tags=<mode>"));
976-
case SIGN_SIGN_IF_INVALID:
977-
die(_("'sign-if-invalid' is not a valid mode for "
978-
"git fast-export with --signed-tags=<mode>"));
979968
default:
980969
BUG("invalid signed_commit_mode value %d", signed_commit_mode);
981970
}

0 commit comments

Comments
 (0)