Re: [PATCH v3 01/13] parse-options: allow for hidden aliases
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Sep 14, 2026, 09:33 UTC
- Message-ID
- <CAOLa=ZSh_H9tjnjEsRrmGXm1Ht+3a=gRaGibO6BKZvvkEabesQ@mail.gmail.com>
- In-Reply-To
- <20260909-b4-pks-unify-ref-storage-format-v3-1-ca041fb40ad8@pks.im>
TPatrick Steinhardt <ps@pks.im> writes:
Show 7 quoted lines
> The `OPT_ALIAS()` option can be used to create an exact alias that maps > one option name to the same semantics as another option name. This > option type is especially useful when deprecating an old name in favor > of a new one. But curiously enough, we don't have the infrastructure in > place to properly support this use case because we don't expose the > ability to hide the alias via `PARSE_OPT_HIDDEN`. >
If we're going to hide the alias, do we need to even use an alias?
❯ ~/code/git/build/bin-wrappers/git.thisseries init --foo
error: unknown option `foo'
usage: git init [-q | --quiet] [--bare] [--template=<template-directory>]
[--separate-git-dir <git-dir>] [--object-format=<format>]
[--ref-storage-format=<format>]
[-b <branch-name> | --initial-branch=<branch-name>]
[--shared[=<permissions>]] [<directory>] --[no-]template <template-directory>
directory from which templates will be used
--[no-]bare create a bare repository
--shared[=<permissions>]
specify that the git repository is to be
shared amongst several users
-q, --[no-]quiet be quiet
--[no-]separate-git-dir <gitdir>
separate git dir from working tree
-b, --[no-]initial-branch <name>
override the name of the initial branch
--[no-]object-format <hash>
specify the hash algorithm to use
--[no-]ref-storage-format <format>
specify the reference storage format to use❯ ~/code/git/build/bin-wrappers/git.withouthide init --foo
error: unknown option `foo'
usage: git init [-q | --quiet] [--bare] [--template=<template-directory>]
[--separate-git-dir <git-dir>] [--object-format=<format>]
[--ref-storage-format=<format>]
[-b <branch-name> | --initial-branch=<branch-name>]
[--shared[=<permissions>]] [<directory>] --[no-]template <template-directory>
directory from which templates will be used
--[no-]bare create a bare repository
--shared[=<permissions>]
specify that the git repository is to be
shared amongst several users
-q, --[no-]quiet be quiet
--[no-]separate-git-dir <gitdir>
separate git dir from working tree
-b, --[no-]initial-branch <name>
override the name of the initial branch
--[no-]object-format <hash>
specify the hash algorithm to use
--[no-]ref-storage-format <format>
specify the reference storage format to use
--[no-]ref-format <format>
alias of --ref-storage-formatPerhaps it doesn't make sense to add flags to OPT_ALIAS() at all? But this is indeed an alias and seems like the correct option to use, but feels wasted. I'm okay to keep it as is.
> Introduce a new `OPT_ALIAS_F()` function that allows the user to pass > flags and propagate these flags when rewriting aliases to match their > respective source options.
[snip]