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

Re: [PATCH 3/4] ls-remote: use parse-options api

From
Thomas Gummerer <t.gummerer@gmail.com>
Date
Jan 17, 2016, 17:27 UTC
Message-ID
<20160117172706.GD7100@hank>
In-Reply-To
<20160117144409.GA15519@sigill.intra.peff.net>
On 01/17, Jeff King wrote:
Show 26 quoted lines
> On Sun, Jan 17, 2016 at 12:04:01PM +0100, Thomas Gummerer wrote:
>
> > Currently ls-remote uses a hand rolled parser for the its command line
> > arguments.  Use the parse-options api instead of the hand rolled parser
> > to simplify the code and make it easier to add new arguments.  In
> > addition this improves the help message.
>
> Sounds like a good idea.
>
> > +	int tags = 0, heads = 0, refs = 0;
> > [...]
> > +		OPT_SET_INT('t', "tags", &tags, N_("limit to tags"), REF_TAGS),
> > +		OPT_SET_INT('h', "heads", &heads, N_("limit to heads"), REF_HEADS),
> > +		OPT_SET_INT(0, "refs", &refs, N_("no magic fake tag refs"), REF_NORMAL),
> > [...]
> > +	flags = tags | heads | refs;
>
> Is there any reason these can't be:
>
>   OPT_BIT('t', "tags", &flags, N_("limit to tags"), REF_TAGS),
>   OPT_BIT('h', "heads", &flags, N_("limit to heads"), REF_HEADS),
>   OPT_BIT(0, "refs", &flags, N_("no magic fake tag refs"), REF_NORMAL),
>
> to make their interaction more obvious? I wondered if there was
> anything tricky going on (like some of the bits for each option
> overlapping), but I didn't see anything.

I was looking for something like this, but totally overlooked it when going through the docs. Thanks, will change.

Show 5 quoted lines
> > +		OPT_SET_INT(0, "refs", &refs, N_("no magic fake tag refs"), REF_NORMAL),
>
> I imagine you took the help string from the comment in check_ref. We can
> probably come up with something more descriptive for the user-facing
> string. :) How about "do not show peeled tags"?

Indeed, I wasn't really happy about it, but couldn't come up with anything better. Your version sounds much better, will fix.

Show 7 quoted lines
> > +		OPT_STRING(0, "upload-pack", &uploadpack, N_("exec"),
> > +			   N_("path of git-upload-pack on the remote host")),
> > +		OPT_STRING(0, "exec", &uploadpack, N_("exec"),
> > +			   N_("path of git-upload-pack on the remote host")),
>
> Since these are redundant with each other, should we declare one
> "hidden" to not appear in "-h" output?

Makes sense, I'll declare the exec option as hidden, as that's the one that's not documented anywhere else either.

Show 6 quoted lines
> > +		OPT_SET_INT(0, "get-url", &get_url,
> > +			    N_("take url.<base>.insteadOf into account"), 1),
>
> Should this one be OPT_BOOL? I think "--no-get-url" works either way (it
> resets the variable to 0), but OPT_BOOL communicates the intent more
> clearly, I think.
Makes sense, will change in the re-roll.
Show 9 quoted lines
>
> > +		OPT_SET_INT(0, "exit-code", &status,
> > +			    N_("exit with exit code 2 if no matching refs are found"), 2),
>
> This one can't be OPT_BOOL, obviously. What happens with
> "--no-exit-code"? We'll set it back to "0", which I think is the right
> thing to do. Good.
>
> The rest of the patch looked good to me.
Thanks for the review!
>
> -Peff

-- Thomas

Previous: Jeff KingNext: Thomas Gummerer
Message 8 of 44 in “ls-remote: introduce symref argument”
  1. 0/4 ls-remote: introduce symref argumentThomas Gummerer, Jan 17, 2016
  2. 1/4 ls-remote: document --quiet optionThomas Gummerer, Jan 17, 2016
  3. Jeff KingJan 17, 2016
  4. Thomas GummererJan 17, 2016
  5. 2/4 ls-remote: fix synopsisThomas Gummerer, Jan 17, 2016
  6. 3/4 ls-remote: use parse-options apiThomas Gummerer, Jan 17, 2016
  7. Jeff KingJan 17, 2016
  8. Thomas GummererJan 17, 2016
  9. 4/4 builtin/ls-remote: add support for showing symrefsThomas Gummerer, Jan 17, 2016
  10. Thomas GummererJan 17, 2016
  11. 4/4 ls-remote: add support for showing symrefsThomas Gummerer, Jan 17, 2016
  12. Jeff KingJan 17, 2016
  13. Thomas GummererJan 17, 2016
  14. Junio C HamanoJan 17, 2016
  15. Thomas GummererJan 17, 2016
  16. Jeff KingJan 17, 2016
  17. Thomas GummererJan 17, 2016
  18. Junio C HamanoJan 17, 2016
  19. 0/5 ls-remote: introduce symrefs argumentThomas Gummerer, Jan 18, 2016
  20. 1/5 ls-remote: document --quiet optionThomas Gummerer, Jan 18, 2016
  21. 2/5 ls-remote: document --refs optionThomas Gummerer, Jan 18, 2016
  22. Jeff KingJan 18, 2016
  23. Junio C HamanoJan 18, 2016
  24. Thomas GummererJan 18, 2016
  25. 3/5 ls-remote: fix synopsisThomas Gummerer, Jan 18, 2016
  26. 4/5 ls-remote: use parse-options apiThomas Gummerer, Jan 18, 2016
  27. Jeff KingJan 18, 2016
  28. 5/5 ls-remote: add support for showing symrefsThomas Gummerer, Jan 18, 2016
  29. Jeff KingJan 18, 2016
  30. Jeff KingJan 18, 2016
  31. Thomas GummererJan 18, 2016
  32. Thomas GummererJan 18, 2016
  33. Jeff KingJan 18, 2016
  34. Thomas GummererJan 18, 2016
  35. Junio C HamanoJan 18, 2016
  36. Thomas GummererJan 18, 2016
  37. Jeff KingJan 18, 2016
  38. 0/5 ls-remote: introduce symref argumentThomas Gummerer, Jan 18, 2016
  39. 1/5 ls-remote: document --quiet optionThomas Gummerer, Jan 18, 2016
  40. 2/5 ls-remote: document --refs optionThomas Gummerer, Jan 18, 2016
  41. 3/5 ls-remote: fix synopsisThomas Gummerer, Jan 18, 2016
  42. 4/5 ls-remote: use parse-options apiThomas Gummerer, Jan 18, 2016
  43. 5/5 ls-remote: add support for showing symrefsThomas Gummerer, Jan 18, 2016
  44. Junio C HamanoJan 19, 2016

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.