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

Re: Unify subcommand structure; introduce double dashes for all subcommands?

From
Stefan Beller <stefanbeller@gmail.com>
Date
Aug 10, 2014, 15:26 UTC
Message-ID
<53E78F26.3000701@gmail.com>
In-Reply-To
<xmqqiomodkt9.fsf@gitster.dls.corp.google.com>
On 23.07.2014 19:52, Junio C Hamano wrote:
Show 22 quoted lines
> Stefan Beller <stefanbeller@gmail.com> writes:
> 
>> A git command is generally setup as:
>> 	git <command> [<subcommand>] [<options>] ...
>>
>> The subcommands vary wildly by the nature of the command. However all
>> subcommands
>> could at least follow one style. The commands bundle, notes, stash and
>> submodule
>> have subcommands without two leading dashes (i.e. git stash list) as
>> opposed to all
>> other commands (i.e. git tag --list).
> 
> Sounds familiar.  E.g. here is a similar thread about a year ago.
> 
>   http://thread.gmane.org/gmane.comp.version-control.git/231376/focus=231478
> 
> Further discussions to make the plan more concrete is very much
> welcomed.
> 
> Thanks.
> 

So I'd want to add have the subcommands without double dashes ideally. It's just less typing and more english like, not cryptic with dashes. This may come handy for newcomers/beginners using git. It also benefits the powerusers of git as you spare the typing of 2 dashes on the subcommand.

I'm currently trying to understand the functions to parse options and I wonder if the following is possible:

If there is an option set by OPT_CMDMODE (such as git tag --delete / --verify) we want to add an internal option, (such as PARSE_OPT_NODASH ?), that you can deliver this CMD_MODE option without leading 2 dashes. The current behavior with leading 2 dashes is still supported, but maybe a warning is printed about deprecating the option with 2 dashes.

Having this change in place will switch over revert, replace, tag and merge-base to having sane subcommands without dashes possible.

Once this change is in, we can rewrite the other commands, which as of now don't require the dashes. Coincidentally these commands heavily rely on option parsing themselves, such as git-notes having this code in place:

	if (argc < 1 || !strcmp(argv[0], "list"))
		result = list(argc, argv, prefix);
	else if (!strcmp(argv[0], "add"))
		result = add(argc, argv, prefix);
	else if (!strcmp(argv[0], "copy"))
		result = copy(argc, argv, prefix);
	...

Does that make sense? Stefan

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 5 in “Unify subcommand structure; introduce double dashes for all subcommands?”
  1. Stefan BellerJul 23, 2014
  2. Junio C HamanoJul 23, 2014
  3. Stefan BellerAug 10, 2014
  4. Junio C HamanoAug 10, 2014
  5. Stefan BellerAug 10, 2014

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.