Re: [PATCH v3 01/13] parse-options: allow for hidden aliases
From: Junio C Hamano <hidden>
Date: 2026-09-15 14:41:50
Kaartic Sivaraam [off-list ref] writes:
quoted
Perhaps it doesn't make sense to add flags to OPT_ALIAS() at all? ...Just some food for thought. There are a couple of other instances where we are currently using OPT_ALIAS to represent the deprecated variant of an option. They are: 1. `--recursive` is a deprecated alias of `--recurse-submodule` in `git clone` cf. bb62e0a99f (clone: teach --recurse-submodules to optionally take a pathspec, 2017-03-17) and 5c387428f1 (parse-options: don't emit "ambiguous option" for aliases, 2019-04-29) 2. `--negotiation-tip` is a deprecated alias of `--negotiation-restrict` in `git fetch` cf. 1a445fc60b (fetch: add --negotiation-restrict option, 2026-05-19) Note: The documentation clarifies that --negotiation-restrict is the preferred variant but does not mention about deprecation. Since they are not hidden, the deprecated variants still show up in the help output of those commands. So, we appear to be doing fine with a public alias so far. So, may be it is not a big deal if we expose the deprecated option publicly?
The OPT_HIDDEN bit for an option indeed is a mechanism for deprecation and it is not limited to alias. When an option has a clearly better alternative, we would want to eventually remove the old one and have everybody use the new one. For that to happen, we need to let people know that the old thing is on its way out, and "git cmd -h" is a good place to do so. We do not want to use OPT_HIDDEN in earlier half of the deprecation. After sufficient time passes, there will be a lot of new users who are equally unfamiliar with old and new options. Telling them about old way that is on its way out does not help them at all. So at some point, we want to start using OPT_HIDDEN for such options. When nobody uses the old option, we can remove the entry from the options[] array, or we can keep it and use it only to cause an error message (i.e., "This option used to do something, but no longer. Do not use it anymore"). If OPT_ALIAS() does not allow using OPT_HIDDEN, that is a bug in the infrastructure. It does not have to block a new topic that uses OPT_ALIAS(), but we can leave a #leftoverbit mark to invite interested parties to work on fixing it. Thanks.