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

[PATCH/RFC] gitopt - command-line parsing enhancements

From
EWEric Wong <normalperson@yhbt.net>
Date
May 9, 2006, 05:06 UTC
Message-ID
<1147151209168-git-send-email-normalperson@yhbt.net>

Here's my take at a new command-line option parser to reduce wear on my fingers. It handles both long and short options, permuting, automatic abbreviations, required arguments, optional arguments, and bundling.

It doesn't use getopt or argp, so it should be easily portable to non-GNU systems (and only uses git-isms trivially, so other programs can use it easily, too).

I've tested everything lightly but it seems to be working well. The unit test was very helpful throughout. More intensive testing, bugfixes and comments would be greatly appreciated.

It should be pretty easy to convert other git-* programs to use gitopt, and write shell wrappers for git.c like I did with am/checkout/commit. I'll probably do so in a few days once my fingers recover a bit, of course feedback and patches for bug reports/enhancements are encouraged, too.

1 - gitopt: a new command-line option parser for git
	This adds the parser, tests, and some simple changes to
	the git.c wrapper.
2 - update-index: convert to using gitopt
3 - ls-tree: convert to gitopt
4 - ls-files: convert to using gitopt
	These three are fairly straightforward conversions.
	I was somewhat disappointed that update-index didn't take
	kindly to permuting arguments, but it's also a good example
	how to disable permuting via gitopt: a == b
5 - gitopt: convert setup_revisions(), and diff_opt_parse()
	This is a fairly intrusive change that affects several
	important programs.  All the tests still pass, so it must be
	working :)
6 - commit: allow --pretty= args to be abbreviated
	This one isn't strictly dependent on gitopt, and can be
	trivially changed to work without the parent patches.
-- 
Eric Wong
Next: Junio C Hamano
Message 1 of 5 in “gitopt - command-line parsing enhancements”
  1. gitopt - command-line parsing enhancementsEric Wong, May 9, 2006
  2. Junio C HamanoMay 9, 2006
  3. Eric WongMay 9, 2006
  4. Junio C HamanoMay 9, 2006
  5. Eric WongMay 9, 2006

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.