From: John Cai via GitGitGadget Date: Mon, 03 Jan 2022 15:20:20 GMT Subject: [PATCH v2 0/2] reflog.c: switch to use parse-options API Message-ID: In-Reply-To: Switch out manual argv parsing for the reflog expire subcommand to use the parse-options API. This reduces code redundancy by consolidating option parsing logic. changes since v1: * add helper parse_opt_expiry_date so we can use this shared logic to parse the expire date option. * place explicit_expiry inside of cmd_reflog_expire_cb to make it easier to use a callback to set both the value of the timestamp and the explicit_expiry flag. John Cai (2): parse-options.h: add parse_opt_expiry_date helper builtin/reflog.c: switch to use parse-options API for delete subcommand builtin/reflog.c | 168 +++++++++++++++++++++++---------------------- parse-options-cb.c | 7 +- parse-options.h | 1 + 3 files changed, 94 insertions(+), 82 deletions(-) base-commit: 55b058a8bbcc54bd93c733035c995abc7967e539 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1175%2Fjohn-cai%2Fjc%2Freflog-switch-to-option-parse-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1175/john-cai/jc/reflog-switch-to-option-parse-v2 Pull-Request: https://github.com/git/git/pull/1175 Range-diff vs v1: 1: 9bd3c6672c4 < -: ----------- builtin/reflog.c: use parse-options for expire subcommand -: ----------- > 1: bcd74559c24 parse-options.h: add parse_opt_expiry_date helper 2: fffea298642 ! 2: f9de21e0f26 builtin/reflog.c: switch to use parse-options API for delete subcommand @@ Commit message Address NEEDSWORK by switching out manual arg parsing for the parse-options API for the delete subcommand. + Moves explicit_expiry flag into cmd_reflog_expire_cb struct so a + callback can set both the value of the expiration as well as the + explicit_expiry flag. + Signed-off-by: "John Cai" ## builtin/reflog.c ## @@ - #include "revision.h" #include "reachable.h" #include "worktree.h" --#include "parse-options.h" +-/* NEEDSWORK: switch to using parse_options */ +-static const char reflog_expire_usage[] = +-N_("git reflog expire [--expire=