From patchwork Mon Jan 3 15:20:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 12702597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98B30C433EF for ; Mon, 3 Jan 2022 15:20:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233889AbiACPU1 (ORCPT ); Mon, 3 Jan 2022 10:20:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233877AbiACPU0 (ORCPT ); Mon, 3 Jan 2022 10:20:26 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E565C061761 for ; Mon, 3 Jan 2022 07:20:26 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id s1so70529345wra.6 for ; Mon, 03 Jan 2022 07:20:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=49xW7CPFByB0bh8tMhtQZQb24p3bKSZ4ZfW/MD9vf1U=; b=IWI/lE6cd5Bg6FB095SGL0T6BOhmhr1iJ+kFpEES995sOIKViXSF6J3MCpi/lhUPA/ Mm+vHgJdMmmXm5jIqEpB3WNJmMfG8fOPE6j0QOO73J6TyywqYrTF0Pen9XQxCgJKGuNC b2fiec0Cramgfng9YTnbXn9Wv4JR5XrUvY3q8lBN3rJZb7JoHJfsEir3zR3uFXWsDerC dDpwQgZegvA2szXpgOCU+XYVrc8lJ+0Gj32hQbsqBefx6h2mhSrbyxdRyg1uABZjfXCt piXUdpEeVQDQk75KT9915v3ClmOTAYCNiyMxRqUSPHeCjwcDw/LFFCAMDvFauMBJwUd3 ERYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=49xW7CPFByB0bh8tMhtQZQb24p3bKSZ4ZfW/MD9vf1U=; b=YIEYPyKQCxOvTV+dtrFBLlziMBF6F/ucycanfqxLcHCyWG1OQhyeuSMYy5nmhSHi5o 8CfeUr6FXa1NyE3kmq1zVkx086WAL3KQvcOqQ73I+OtA8TQkJzQQaj8TbRiuOQNQp8xT fvNLS2MfUH7Mc5ZrrALStG1gqLV/1J4V2jTmYtCMantuO2pjZhmxROVsvY0L4EtYB/Rg ZB79TokvU5rbzPJBdFsZ/52pGCa9Yhd1i7QtuREwLxRDxI9AwKo4O2kPdZXeUtiUFXAr v+fm7UsAxGT0LfwQ4nOkryuvqMRCpj9tCTObsJCYsS2x7cgG//4mH851hYuIvnoMOuWO WahQ== X-Gm-Message-State: AOAM532aQnL8snoh7R/OC667aJJV2yiswn0q5WRiuWMTTDR+sHU4W8na TBu2Jrgn2Wp7p3xjvgiEyE77+kUgCwQ= X-Google-Smtp-Source: ABdhPJwCnma8Ve3++f9UW04pbeqbk0SWOrePAT0tKhnicao1ByAzr33eXwRAfT/23E7NBeQA5oobeQ== X-Received: by 2002:adf:f188:: with SMTP id h8mr38880639wro.663.1641223224853; Mon, 03 Jan 2022 07:20:24 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h4sm35520035wrf.93.2022.01.03.07.20.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jan 2022 07:20:24 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 03 Jan 2022 15:20:21 +0000 Subject: [PATCH v2 1/2] parse-options.h: add parse_opt_expiry_date helper Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?UmVuw6k=?= Scharfe , John Cai , John Cai Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: John Cai From: John Cai Extract the logic in parse_opt_expiry_date_cb into a helper parse_opt_expiry_date. This is to prepare for the following commit where we need to parse an expiry date that gets passed into a callback function in opt->value as part of a struct. The next commit will utilize this helper in a callback function that aims to wrap the functionality in parse_opt_expiry_date_cb. Signed-off-by: "John Cai" --- parse-options-cb.c | 7 ++++++- parse-options.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/parse-options-cb.c b/parse-options-cb.c index 3c811e1e4a7..3edb88a54d8 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -34,10 +34,15 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset) int parse_opt_expiry_date_cb(const struct option *opt, const char *arg, int unset) +{ + return parse_opt_expiry_date((timestamp_t *)opt->value, arg, unset); +} + +int parse_opt_expiry_date(timestamp_t *t, const char *arg, int unset) { if (unset) arg = "never"; - if (parse_expiry_date(arg, (timestamp_t *)opt->value)) + if (parse_expiry_date(arg, t)) die(_("malformed expiration date '%s'"), arg); return 0; } diff --git a/parse-options.h b/parse-options.h index 275fb440818..0a15bac8619 100644 --- a/parse-options.h +++ b/parse-options.h @@ -301,6 +301,7 @@ enum parse_opt_result parse_opt_unknown_cb(struct parse_opt_ctx_t *ctx, const char *, int); int parse_opt_passthru(const struct option *, const char *, int); int parse_opt_passthru_argv(const struct option *, const char *, int); +int parse_opt_expiry_date(timestamp_t *, const char *, int); #define OPT__VERBOSE(var, h) OPT_COUNTUP('v', "verbose", (var), (h)) #define OPT__QUIET(var, h) OPT_COUNTUP('q', "quiet", (var), (h)) From patchwork Mon Jan 3 15:20:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 12702598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A54F0C433FE for ; Mon, 3 Jan 2022 15:20:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230160AbiACPU3 (ORCPT ); Mon, 3 Jan 2022 10:20:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233899AbiACPU2 (ORCPT ); Mon, 3 Jan 2022 10:20:28 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43657C061761 for ; Mon, 3 Jan 2022 07:20:27 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id e5so70526691wrc.5 for ; Mon, 03 Jan 2022 07:20:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=k+rG/v9aLEtZ0h6ndB7EIVU4qGXxeiiAWb06AjkPJI8=; b=Wf/5AdnfICzBVL0i/6yCriLfIbZl/dGgSkTUxHNv95jDW8nRrVeh1wY4IohgTx/e5v vrAoJu9v0h0nVSK5I0WTDjVRInBpZfeKhe+C6O048bYmGeTdb3iieO7reyi1KaFldQG0 uLhU1WCnoG6fyfHSuB7Jols9UVEA42bxB2u5u35vc5IpuY7UOQd0vTqnQ7T4hmmYxvr1 Al1lDsIxdVmX+kaj8g0IF9UqSSPwLSNuugQr6fUZh/u9b/3LzBpYWljZo8KIcRU8beRt Aqqs/mBgJOwsTsB9E1psUMDVVcReg1946sYmKPczUAMZcsjvakrTPqpJmbgS99SSeEv6 R6pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=k+rG/v9aLEtZ0h6ndB7EIVU4qGXxeiiAWb06AjkPJI8=; b=SJnnc6wfs76NPNvm5gddHhTEka/ZQBeE49Bs01XvLW6dhGfLmp5042Mn1CdLMOJ2D7 fF/Y8HobnJ3Sl9VVrfR2zCbhYF2ooLyWSuQRosCSuRNtfCsJj3TMWFcJCNYggO88L4TM OY98XO286vD1XF+fKKyzCNvF1Ui3cl7eZyiHX0q3mw9U0gSlgFBTPMUMe+czFLubHpB5 tv5EvsUyD8/ilsHXRYiYFSyevfNLhblwTwJuH3q72xJ/OjRv0tnw47qOsFFvEL96Lqc2 PongTbSqhg40n8njURXThDMMHdjSLSEQ687TDe86RKssm+yCAhydU2/+yALt7lMBfGpk y4EQ== X-Gm-Message-State: AOAM530RwDxKhaFx/iVGqjssjj4sOQJfl71sny9PeSTjHVfIufKvHwvo CsedQRMU12zRlVa/MkkprU/kZB/Oi/4= X-Google-Smtp-Source: ABdhPJyQhsPxeTh/VktYkbKTYRrlg8aHkopjQfCKRrWFzuLwFJQdSyEV9+kU6/OTtN4rUaBoKAWHmw== X-Received: by 2002:adf:facb:: with SMTP id a11mr37831461wrs.18.1641223225551; Mon, 03 Jan 2022 07:20:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o10sm39928245wrc.55.2022.01.03.07.20.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jan 2022 07:20:25 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 03 Jan 2022 15:20:22 +0000 Subject: [PATCH v2 2/2] builtin/reflog.c: switch to use parse-options API for delete subcommand Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?UmVuw6k=?= Scharfe , John Cai , John Cai Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: John Cai From: John Cai 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 | 168 ++++++++++++++++++++++++----------------------- 1 file changed, 87 insertions(+), 81 deletions(-) diff --git a/builtin/reflog.c b/builtin/reflog.c index 175c83e7cc2..3552d749e4b 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -12,15 +12,6 @@ #include "reachable.h" #include "worktree.h" -/* NEEDSWORK: switch to using parse_options */ -static const char reflog_expire_usage[] = -N_("git reflog expire [--expire=