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

Re: [PATCH 0/2] Parsing a subcommand using parse-options

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 8, 2011, 19:51 UTC
Message-ID
<7v4nxaj0zn.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1323346028-9201-1-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
>   git stash show
>             ^^ -- The subcommand "show" to the git-stash builtin

Contrasting this with "git tag --list", one uses subcommand verb while the other uses operating mode option and one could say they are inconsistent.

But it does not bother me that much, and for a good reason other than inertia.

When a command whose primary purpose is very clear (e.g. "git tag" and "git branch" are primarily to create these things, just like "git commit" is to create a commit), it is more natural to give the primary mode the main interface so that you do not have to say "git tag create v1.0"; hence operating mode option makes sense than subcommand.

On the other hand, when a command does not have a clear primary mode (e.g. if you save a stash you must be able to use (i.e. apply or pop) the saved one and both are equally important feature), but its primary purpose is to dispatch various different operation, it makes more sense to name them as subcommands. You _could_ make all of them into operating mode options, but that only requires more typing, i.e. "git stash --save"/"git stash --pop", without adding much value to the command. In addition, it invites unnecessary confusion "what is the default mode of operation, and is it really that important to be the default?", because not requiring an explicit "subcommand" but merely allowing "operation mode option" implies that you can say "git cmd" without anything, i.e. there must be some default.

For "stash", "save" has been the default merely by historical accident, but that has been rectified (it now requires you do not have any message for the quick stash "git satsh<ENTER>" to work). There really isn't any "default" operating mode to the command, and the command is a dispatcher to its subcommands.

Previous: Ramkumar Ramachandra
Message 4 of 4 in “Parsing a subcommand using parse-options”
  1. 0/2 Parsing a subcommand using parse-optionsRamkumar Ramachandra, Dec 8, 2011
  2. 1/2 parse-options: introduce OPT_SUBCOMMANDRamkumar Ramachandra, Dec 8, 2011
  3. 2/2 bundle: rewrite builtin to use parse-optionsRamkumar Ramachandra, Dec 8, 2011
  4. Junio C HamanoDec 8, 2011

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.