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
Junio C Hamano <gitster@pobox.com>
Date
Jul 22, 2025, 20:54 UTC
Message-ID
<xmqq1pq8rlo5.fsf@gitster.g>
In-Reply-To
<20250722180818.1043014-2-jltobler@gmail.com>
Justin Tobler <jltobler@gmail.com> writes:
Show 14 quoted lines
> Both git-switch(1) and git-restore(1) inherit some common options from
> git-checkout(1). One such option is the `--merge` flag and its
> accompanying short flag `-m`.
>
> In previous discussion[1] around removing the experimental marker for
> git-switch(1), it has been suggested that this short flag could instead
> be used for an option similar to `--move` from git-branch(1). Such a
> feature is not yet implemented for this command, but reserving a short
> flag for an uncommon option is unnecessary and hinders potential future
> extension.
>
> While these commands are still marked as experimental, remove the `-m`
> flag from both git-switch(1) and git-restore(1) and update the
> documentation accordingly.

Surely the whole point of marking the commands as experimental is to allow us to make a change like this one.

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.

> 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.

Previous: Justin ToblerNext: Justin Tobler
Message 3 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.