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

Re: [PATCH v2 7/9] builtin/send-pack.c: Use option parsing API

From
Jeff King <peff@peff.net>
Date
Aug 21, 2015, 15:06 UTC
Message-ID
<20150821150613.GB565@sigill.intra.peff.net>
In-Reply-To
<CAD0k6qSp5af+N9QvjAxw1M19ytzh_n4repFA1+5Nq6v+px+fPw@mail.gmail.com>
On Wed, Aug 19, 2015 at 03:46:25PM -0400, Dave Borowitz wrote:
Show 22 quoted lines
> >> +       unsigned dry_run = 0;
> >> +       unsigned send_mirror = 0;
> >> +       unsigned force_update = 0;
> >> +       unsigned quiet = 0;
> >> +       unsigned push_cert = 0;
> >> +       unsigned use_thin_pack = 0;
> >> +       unsigned atomic = 0;
> >> +       unsigned stateless_rpc = 0;
> >
> > First I thought:
> >     You could write to the args flags directly from the options. No
> > need to have (most of)
> >     the variables around here and copy over the values. You'd need to
> > use OPT_BIT instead
> >     for setting a specific bit though
> > but then I realized we do not have a direct bit field in args, which
> > would make it a bit unreadable.
> 
> Right, and &args->push_cert etc. is invalid, and I didn't know if it
> was ok to expand the args struct to be several words longer. But I'm
> not a C programmer so I'm happy to take suggestions how to make this
> more idiomatic.

I think it would be fine to expand it. The reason to use bitfields is to save memory, and there is literally only one of these structs per program. I'm sure we can afford the extra dozen bytes.

Making the struct members single-bits also communicates to readers that they are true booleans, but I think a comment in the declaration of send_pack_args could do the same.

-Peff
Previous: Dave BorowitzNext: Dave Borowitz
Message 15 of 19 in “Flags and config to sign pushes by default”
  1. 0/9 Flags and config to sign pushes by defaultDave Borowitz, Aug 19, 2015
  2. 1/9 Documentation/git-push.txt: Document when --signed may failDave Borowitz, Aug 19, 2015
  3. 2/9 Documentation/git-send-pack.txt: Flow long synopsis lineDave Borowitz, Aug 19, 2015
  4. Junio C HamanoAug 19, 2015
  5. Dave BorowitzAug 19, 2015
  6. Junio C HamanoAug 19, 2015
  7. Junio C HamanoSep 11, 2015
  8. 3/9 Documentation/git-send-pack.txt: Document --signedDave Borowitz, Aug 19, 2015
  9. 4/9 gitremote-helpers.txt: Document pushcert optionDave Borowitz, Aug 19, 2015
  10. 5/9 transport: Remove git_transport_options.push_certDave Borowitz, Aug 19, 2015
  11. 6/9 config.c: Expose git_parse_maybe_boolDave Borowitz, Aug 19, 2015
  12. 7/9 builtin/send-pack.c: Use option parsing APIDave Borowitz, Aug 19, 2015
  13. Stefan BellerAug 19, 2015
  14. Dave BorowitzAug 19, 2015
  15. Jeff KingAug 21, 2015
  16. 8/9 Support signing pushes iff the server supports itDave Borowitz, Aug 19, 2015
  17. Junio C HamanoAug 19, 2015
  18. Dave BorowitzAug 19, 2015
  19. 9/9 Add a config option push.gpgSign for default signed pushesDave Borowitz, Aug 19, 2015

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.