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

Re: [PATCH 1/2] builtin: remove merge short flag for switch and restore

From
Justin Tobler <jltobler@gmail.com>
Date
Jul 22, 2025, 21:16 UTC
Message-ID
<hjvkryax5gq7im6m6jnlczykfctntnqf73xicbrfehe2j2c3rt@62m3urrkecg7>
In-Reply-To
<xmqq1pq8rlo5.fsf@gitster.g>
On 25/07/22 01:54PM, Junio C Hamano wrote:
Show 6 quoted lines
> Justin Tobler <jltobler@gmail.com> writes:
> I doubt that this particular one is a sensible change, though.
> 
> "git checkout -m <another-branch>" is one of the most frequently
> used operation in my daily workflow, and having to type "git switch
> --merge" (not having to learn to do so) would be a major annoyance.

In general, I think it is best to reserve short flags for relavitely common operations. That way, if a new super useful option were to be introduced that we want a short flag for, there is a better chance a good flag choice will be available.

That being said, I incorrectly assumed `--merge` was an uncommon option. If there are workflows that make frequent use of this option, we should drop this patch and keep the short flag available.

Show 15 quoted lines
> > The `--conflict` flag is also now defined
> > explicitly for each command as to remain alongside its related `--merge`
> > companion.
> 
> I doubt this is a wise move.  Unless we are planning to make the
> option diverge across these three commands, that is.
> 
> The main logic that implements the "move to a different branch,
> while merging local changes into the new base" does use these two
> things together in the same code path (in merge_working_tree()).
> The same for "check out a single path out to the working tree",
> which does use these two things together in the same code path (in
> checkout_merged()).  I actually think keeping it in the common part
> would help the readers of the code even more---by making it clear
> that these three commands parse the option exactly the same way.

That's fair. If we do want to keep this patch, we could still keep it as part of `builtin/checkout.c:add_common_options()`, but add an argument to toggle short flag usage. This way it is at least clear to readers of the code that it is same option.

Thanks, -Justin

Previous: Junio C HamanoNext: Justin Tobler
Message 4 of 11 in “builtin: unmark git-switch and git-restore as experimental”
  1. 0/2 builtin: unmark git-switch and git-restore as experimentalJustin Tobler, Jul 22, 2025
  2. 1/2 builtin: remove merge short flag for switch and restoreJustin Tobler, Jul 22, 2025
  3. Junio C HamanoJul 22, 2025
  4. Justin ToblerJul 22, 2025
  5. 2/2 builtin: unmark git-switch and git-restore as experimentalJustin Tobler, Jul 22, 2025
  6. Junio C HamanoJul 22, 2025
  7. Justin ToblerJul 22, 2025
  8. Junio C HamanoJul 22, 2025
  9. Justin ToblerJul 22, 2025
  10. builtin: unmark git-switch and git-restore as experimentalJustin Tobler, Jul 28, 2025
  11. Junio C HamanoJul 28, 2025

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.