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

Re: [PATCH 2/2] read-tree: migrate to parse-options

From
Stephen Boyd <bebarino@gmail.com>
Date
Jun 25, 2009, 01:36 UTC
Message-ID
<4A42D49F.8010805@gmail.com>
In-Reply-To
<7vws721ao9.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Sorry, but I have to ask: Why?

I think there are advantages to parse-optification, for plumbing and porcelains. Two reasons I see are:

1. Providing a unified way of handling options
2. Providing a consistent usage message format

Obviously, 1 reduces the bugs associated with parsing options (strcmp vs. prefixcmp, incorrect argv+offset). For number 2, I think it helps users when they see the same style of usage messages with each command. It's also nice to get a quick help message without opening the man pages or using git help <command>.

Admittedly this patch ends up adding 20 or so lines. Do the above points justify this? I think so. I think the added lines can be attributed to the rougher edges of parse-opts exposed by this patch. You can't take the address of bit fields, so 6 lines are dealing with this problem. Where are the other 15 lines coming from?

Looking over it again, I think I may be able to cut the overhead down by refactoring three of the callbacks into boolean options. There's a lot of duplication there, which can be simplified. I was trying to make this a straight port which is probably not so good for convincing you that it's worthwhile.

For now, I don't mind this patch being dropped (there's an ambiguity in the callbacks returning non-zero I'd like to fix too). I'll try and get a new patch (or maybe this patch with the oneline fix and a refactoring patch) out later tonight that actually reduces the amount of lines, instead of grossly adding to them.

Previous: Junio C HamanoNext: Stephen Boyd
Message 4 of 12 in “read-tree: convert unhelpful usage()'s to helpful die()'s”
  1. 1/2 read-tree: convert unhelpful usage()'s to helpful die()'sStephen Boyd, Jun 24, 2009
  2. 2/2 read-tree: migrate to parse-optionsStephen Boyd, Jun 24, 2009
  3. Junio C HamanoJun 24, 2009
  4. Stephen BoydJun 25, 2009
  5. 2/2 read-tree: migrate to parse-optionsStephen Boyd, Jun 25, 2009
  6. Johannes SixtJun 25, 2009
  7. Stephen BoydJun 26, 2009
  8. 1/2 read-tree: convert unhelpful usage()'s to helpful die()'sStephen Boyd, Jun 26, 2009
  9. 2/2 read-tree: migrate to parse-optionsStephen Boyd, Jun 26, 2009
  10. Stephen BoydJun 26, 2009
  11. Junio C HamanoJun 26, 2009
  12. Stephen BoydJun 27, 2009

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.