From 2f8fd208c36bf2e88f949d0c4059214dfcb2a717 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Wed, 17 Sep 2025 20:14:26 +0200 Subject: gpg-interface: refactor 'enum sign_mode' parsing The definition of 'enum sign_mode' as well as its parsing code are in "builtin/fast-export.c". This was fine because `git fast-export` was the only command with '--signed-tags=' or '--signed-commits=' options. In a following commit, we are going to add a similar option to `git fast-import`, which will be simpler, easier and cleaner if we can reuse the 'enum sign_mode' defintion and parsing code. So let's move that definition and parsing code from "builtin/fast-export.c" to "gpg-interface.{c,h}". While at it, let's fix a small indentation issue with the arguments of parse_opt_sign_mode(). Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- gpg-interface.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gpg-interface.c') diff --git a/gpg-interface.c b/gpg-interface.c index 06e7fb5060..2f4f0e32cb 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -1125,3 +1125,20 @@ out: FREE_AND_NULL(ssh_signing_key_file); return ret; } + +int parse_sign_mode(const char *arg, enum sign_mode *mode) +{ + if (!strcmp(arg, "abort")) + *mode = SIGN_ABORT; + else if (!strcmp(arg, "verbatim") || !strcmp(arg, "ignore")) + *mode = SIGN_VERBATIM; + else if (!strcmp(arg, "warn-verbatim") || !strcmp(arg, "warn")) + *mode = SIGN_WARN_VERBATIM; + else if (!strcmp(arg, "warn-strip")) + *mode = SIGN_WARN_STRIP; + else if (!strcmp(arg, "strip")) + *mode = SIGN_STRIP; + else + return -1; + return 0; +} -- cgit v1.2.3