From patchwork Wed Jan 5 04:06:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 12704012 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 093A6C433F5 for ; Wed, 5 Jan 2022 04:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236571AbiAEEGF (ORCPT ); Tue, 4 Jan 2022 23:06:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230332AbiAEEGE (ORCPT ); Tue, 4 Jan 2022 23:06:04 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71B11C061761 for ; Tue, 4 Jan 2022 20:06:04 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id t26so80199092wrb.4 for ; Tue, 04 Jan 2022 20:06:04 -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=eTfkk4HOotRUKsCSudw2gHUvXl2UtqgFfmupeYhtB8w=; b=dmQi+Q7JNDeZ3TVroNScK+z3aLOICyHKTs8RuaFsdFJ4iWi8t3jqwGgEUtV4JK7LIh u5Er8KO6N8Lrg9t731uutUiwEEBzRs8iunNhqD/rYw+W7ve/+P8+IGgCcBvPdGE43cR2 HpQAhvhpP39qe3RnVOHTpRA07Q1BF8LjoFT0YS2v8ItbSn4o0L6Er+2XbLx9BAfSawQY /9dgowAoaaO5iQ7DQjPHbpfA7zzzRFgb32h36/fhY+4DzJG1dkBGqMFRoufkNc3UpnAJ AT52w1vYRj9d41Nvyo70qKHjF9uPaO9b3u+IL72u77AE2p4P9Ql6RXNxoYy7JgF3fg41 QaKQ== 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=eTfkk4HOotRUKsCSudw2gHUvXl2UtqgFfmupeYhtB8w=; b=8LekEkwuhVSg4u/lDP0SYp2eQtcjgxg6bfUCeZS/U2RxLeHCKdZMNCefzS37L1k9uC iNpahplyrz7wdBnJvDpHFoaQE/t/yhOLavKwT1AfhyQJ2jzL/vKXCGcOcndI6F9tJ//j CfJ1FfbYHPOuLHH8Vgp0zfEMxo12aGHMmh8d3tfetgaaReJiG/HIRusac1mTT1AG84/q hGPLwbkNL6OL8S46rGAxuXhXsAE2AAIEnKY11RCf+aUvzFp6069kj2Q+Xwk3o4xZ/03y K5yhXlN3xO1nWwpgZXlcXVxBwDMtcFdFrtbhFDghKTwU4NZCogrFbL1AoiHDrOZJmSDn MchQ== X-Gm-Message-State: AOAM533MmOdEiZbEYOqRP/8mwDbshXP7xt2XENvS0Kpv/P6nv7jJI6rt TftyN6OuLZnWwktBGzIldbRq1P8UhBw= X-Google-Smtp-Source: ABdhPJx62oQOMi0A+HuPKwLhUrh+p74NZSYwJyr3cP5mslMNZx7Gl5feEfK6SDhJDgIpjKdbuJGaog== X-Received: by 2002:a5d:6d84:: with SMTP id l4mr45789149wrs.61.1641355562820; Tue, 04 Jan 2022 20:06:02 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z6sm1646729wmp.9.2022.01.04.20.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jan 2022 20:06:02 -0800 (PST) Message-Id: In-Reply-To: References: Date: Wed, 05 Jan 2022 04:06:01 +0000 Subject: [PATCH v4] builtin/reflog.c: use parse-options api for expire, delete subcommands 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 Switching out manual arg parsing for the parse-options API for the expire and delete subcommands. Move explicit_expiry flag into cmd_reflog_expire_cb struct so callbacks can set both the value of the timestamp as well as the explicit_expiry flag. Signed-off-by: "John Cai" --- reflog.c: switch to use parse-options API 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. NOTE: this patch was based off of next. I know now that I should base it off of master. But practically, nothing in master touched reflog.c except for ab/reflog-prep changes since v3: * fixed indentation changes since v2: * got rid of parse_opt_expiry_date helper based on feedback from Junio. Just call parse_expiry_date directly in the callbacks, and don't worry about unset, as we can just set the PARSE_OPT_NONEG flag for --expire and --expire-unreachable since the original code didn't support a negated version of those flags anyway. The documentation also explicitly states to use "never" as the argument. * fix places where we set int i inside a for loop construct. Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1175%2Fjohn-cai%2Fjc%2Freflog-switch-to-option-parse-v4 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1175/john-cai/jc/reflog-switch-to-option-parse-v4 Pull-Request: https://github.com/git/git/pull/1175 Range-diff vs v3: 1: 99a97e6ee52 ! 1: 0efdf3d2cb1 builtin/reflog.c: use parse-options api for expire, delete subcommands @@ builtin/reflog.c: static void set_reflog_expiry_param(struct cmd_reflog_expire_c +static const char * reflog_expire_usage[] = { + N_("git reflog expire [--expire=