git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: John Cai <johncai86@gmail.com>
Cc: John Cai via GitGitGadget <gitgitgadget@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 1/2] builtin/reflog.c: use parse-options for expire subcommand
Date: Sun, 2 Jan 2022 10:00:34 +0100	[thread overview]
Message-ID: <602b2039-8d74-8063-9757-e67ba5db1141@web.de> (raw)
In-Reply-To: <9D4E4253-6EBE-4AA7-86A5-413A732C6E38@gmail.com>

Am 01.01.22 um 20:09 schrieb John Cai:
>
>
>> On Jan 1, 2022, at 3:16 AM, René Scharfe <l.s.r@web.de> wrote:
>>
>> The problem is that the default value can vary between reflogs and we
>> only know which ones are to be expired after option parsing, right?
>
> That’s a good point. Does it matter that the default value varies between reflogs?
>
> Would something like this suffice?
>
> -       for (i = 1; i < argc; i++) {
> -               const char *arg = argv[i];
> -               if (starts_with(arg, "--expire=")) {
> -                       explicit_expiry |= EXPIRE_TOTAL;
> -               } else if (starts_with(arg, "--expire-unreachable=")) {
> -                       explicit_expiry |= EXPIRE_UNREACH;
> -               }
> -       }
> -
>         argc = parse_options(argc, argv, prefix, options, reflog_expire_usage, 0);
>
> +       if (cb.cmd.expire_total != default_reflog_expire)
> +               explicit_expiry |= EXPIRE_TOTAL;
> +       if (cb.cmd.expire_unreachable != default_reflog_expire_unreachable)
> +               explicit_expiry |= EXPIRE_UNREACH;

This would ignore --expire and -expire-unreachable options with the
value of default_reflog_expire and default_reflog_expire_unreachable,
respectively.  E.g. "git reflog expire --expire=90.days.ago refs/stash"
would not expire anything.

René

  reply	other threads:[~2022-01-02  9:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-31  6:29 [PATCH 0/2] reflog.c: switch to use parse-options API John Cai via GitGitGadget
2021-12-31  6:29 ` [PATCH 1/2] builtin/reflog.c: use parse-options for expire subcommand John Cai via GitGitGadget
2022-01-01  2:06   ` John Cai
2022-01-01 11:16     ` René Scharfe
2022-01-01 19:09       ` John Cai
2022-01-02  9:00         ` René Scharfe [this message]
2021-12-31  6:29 ` [PATCH 2/2] builtin/reflog.c: switch to use parse-options API for delete subcommand John Cai via GitGitGadget
2022-01-03 15:20 ` [PATCH v2 0/2] reflog.c: switch to use parse-options API John Cai via GitGitGadget
2022-01-03 15:20   ` [PATCH v2 1/2] parse-options.h: add parse_opt_expiry_date helper John Cai via GitGitGadget
2022-01-04  2:26     ` Junio C Hamano
2022-01-03 15:20   ` [PATCH v2 2/2] builtin/reflog.c: switch to use parse-options API for delete subcommand John Cai via GitGitGadget
2022-01-04  2:36     ` Junio C Hamano
2022-01-04 17:41   ` [PATCH v3] builtin/reflog.c: use parse-options api for expire, delete subcommands John Cai via GitGitGadget
2022-01-04 22:04     ` Junio C Hamano
2022-01-05  4:06     ` [PATCH v4] " John Cai via GitGitGadget
2022-01-05 20:34       ` Junio C Hamano
2022-01-06 19:06       ` [PATCH v5] " John Cai via GitGitGadget
2022-01-06 21:09         ` Junio C Hamano
2022-01-06 21:32           ` John Cai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=602b2039-8d74-8063-9757-e67ba5db1141@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johncai86@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).