Re: [PATCH 1/2] builtin/reflog.c: use parse-options for expire subcommand

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 01.01.22 um 20:09 schrieb John Cai:
>
>
>> On Jan 1, 2022, at 3:16 AM, René Scharfe <l.s.r@xxxxxx> 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é




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux