Re: [PATCH v3 03/15] merge-tree: add option parsing and initial shell for real merge function
- From
Elijah Newren <newren@gmail.com>
- Date
- Feb 3, 2022, 16:20 UTC
- Message-ID
- <CABPp-BF8VoQ7F7yvfzrpQEZwErxHzb9x8M_R9PrrM7vWzw=wSw@mail.gmail.com>
- In-Reply-To
- <220203.86wnic5lba.gmgdl@evledraar.gmail.com>
On Thu, Feb 3, 2022 at 1:52 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> > On Thu, Feb 03 2022, Elijah Newren wrote: >
[...]
Show 23 quoted lines
> > ...also, even if we did require the `--write-tree` flag, we'd still > > have to look at argc. Since the option parsing handles both modes, > > someone could leave off --write-tree, but include a bunch of other > > options that only make sense with --write-tree. Individually checking > > the setting of every extra flag along with write_tree is a royal pain > > and I don't want to repeat that for each new option added. Simply > > checking argc allows you to provide an error message if the user does > > that. > > > > (And I think it's sad that in Git we often forgot to warn and notify > > users of options that are only functional with certain other > > arguments; it makes it harder for users to figure out, and has in the > > past even made it harder for other developers to figure out what was > > meant and how things are to be used. I think I've seen multiple Git > > devs be confused over ls-files --directory and --no-empty-directory > > options, assuming they'd do something sensible for tracked files, when > > in fact those arguments are simply ignored because they are only > > modifiers for how untracked files are treated.) > > There's a much simpler way to do what you're trying to do here which is > to only parse --write-tree, and as soon as you have that pass off two > one function or the other, and have those functions call > parse_options().
But that makes --write-tree a mandatory argument when trying to use that mode, right? If so, that is not a simpler way to do what I'm trying to do at all; it breaks my intended usage.
--write-tree is a documentation-only construct that users should never have to pass.
Also, what happens if we remove the --trivial-merge flag and its whole mode after a sufficient deprecation period? Would the --write-tree parameter remain required in your model to select the only existing mode, simply due to us having gone through a transition period?