git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
René Scharfe <l.s.r@web.de>
Date
Jan 2, 2022, 09:00 UTC
Message-ID
<602b2039-8d74-8063-9757-e67ba5db1141@web.de>
In-Reply-To
<9D4E4253-6EBE-4AA7-86A5-413A732C6E38@gmail.com>
Am 01.01.22 um 20:09 schrieb John Cai:
Show 26 quoted lines
>
>
>> 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é
Previous: John CaiNext: John Cai via GitGitGadget
Message 6 of 19 in “reflog.c: switch to use parse-options API”
  1. 0/2 reflog.c: switch to use parse-options APIJohn Cai via GitGitGadget, Dec 31, 2021
  2. 1/2 builtin/reflog.c: use parse-options for expire subcommandJohn Cai via GitGitGadget, Dec 31, 2021
  3. John CaiJan 1, 2022
  4. René ScharfeJan 1, 2022
  5. John CaiJan 1, 2022
  6. René ScharfeJan 2, 2022
  7. 2/2 builtin/reflog.c: switch to use parse-options API for delete subcommandJohn Cai via GitGitGadget, Dec 31, 2021
  8. 0/2 reflog.c: switch to use parse-options APIJohn Cai via GitGitGadget, Jan 3, 2022
  9. 1/2 parse-options.h: add parse_opt_expiry_date helperJohn Cai via GitGitGadget, Jan 3, 2022
  10. Junio C HamanoJan 4, 2022
  11. 2/2 builtin/reflog.c: switch to use parse-options API for delete subcommandJohn Cai via GitGitGadget, Jan 3, 2022
  12. Junio C HamanoJan 4, 2022
  13. builtin/reflog.c: use parse-options api for expire, delete subcommandsJohn Cai via GitGitGadget, Jan 4, 2022
  14. Junio C HamanoJan 4, 2022
  15. builtin/reflog.c: use parse-options api for expire, delete subcommandsJohn Cai via GitGitGadget, Jan 5, 2022
  16. Junio C HamanoJan 5, 2022
  17. builtin/reflog.c: use parse-options api for expire, delete subcommandsJohn Cai via GitGitGadget, Jan 6, 2022
  18. Junio C HamanoJan 6, 2022
  19. John CaiJan 6, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.