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

Re: [PATCH 6/9] builtin-init-db.c: use parse_options()

From
Michele Ballabio <barra_cuda@katamail.com>
Date
Jul 24, 2008, 20:07 UTC
Message-ID
<200807242207.02195.barra_cuda@katamail.com>
In-Reply-To
<4888AAB2.5050007@free.fr>
On Thursday 24 July 2008, Olivier Marin wrote:
Show 7 quoted lines
> Michele Ballabio a écrit :
> > 
> > +	const struct option options[] = {
> > +		OPT_STRING(0, "template", &template_dir, "dir",
> > +			   "directory from which templates will be used"),
> 
> Perhaps "path", "path to the template repository" to stay consistent with clone.
Ok.
> > +		OPT_BOOLEAN(0, "bare", &bare, "set up a bare repo"),
> 
> s/set up/setup/ and s/repo/repository/?
I think "set up a bare repository" will be fine.
> > +		{ OPTION_CALLBACK, 0, "shared", &shared_repository,
> > +		  "type", "type of shared repository",
> 
> What about "permissions", "setup a shared repository"?
Ok, but with s/setup/set up/.
> > +		  PARSE_OPT_OPTARG, parse_opt_shared_cb, PERM_GROUP },
> 
> Are you sure the default value is really used here?
Yes. Perhaps I don't understand your question. Can you explain what you mean?
Show 7 quoted lines
> Also, perhaps we can play it safer by avoiding changing "share_repository"
> directly.
> 
> $ git init -> shared_repository == PERM_UMASK
> $ git init --shared --no-shared -> shared_repository == 0
> 
> It works because PERM_UMASK == 0, but it is a side effect. Don't you think?
Would you like this better, with PARSE_OPT_NONEG?

+               { OPTION_CALLBACK, 0, "shared", &shared_repository, +                 "permissions", "set up a shared repository", +                 PARSE_OPT_OPTARG | PARSE_OPT_NONEG, parse_opt_shared_cb, PERM_GROUP },

Or do you prefer changing the callback like this:

+static int parse_opt_shared_cb(const struct option *opt, const char *arg, +                              int unset) +{ +       *(int *)(opt->value) = unset ? PERM_UMASK : git_config_perm("arg", arg); +       return 0; +}

Show 8 quoted lines
> > +		OPT_BIT('q', "quiet", &flags, "be quiet", INIT_DB_QUIET),
> 
> OPT__QUIET(&quiet),
> 
> if (quiet)
> 	flags |= INIT_DB_QUIET;
> 
> to use the same quiet option everywhere?

I thought about it and decided against ;) And it's one line vs four (counting "int quiet = 0;"). But I see your point.

Previous: Johannes SchindelinNext: Michele Ballabio
Message 20 of 31 in “Extend use of parse_options()”
  1. 0/9 Extend use of parse_options()Michele Ballabio, Jul 23, 2008
  2. 1/9 builtin-verify-tag.c: use parse_options()Michele Ballabio, Jul 23, 2008
  3. Olivier MarinJul 24, 2008
  4. Johannes SchindelinJul 24, 2008
  5. Olivier MarinJul 25, 2008
  6. Johannes SchindelinJul 26, 2008
  7. builtin-verify-tag: fix -v option parsingOlivier Marin, Jul 28, 2008
  8. Johannes SchindelinJul 28, 2008
  9. Olivier MarinJul 28, 2008
  10. Johannes SchindelinJul 28, 2008
  11. 2/9 builtin-write-tree.c: use parse_options()Michele Ballabio, Jul 23, 2008
  12. 3/9 builtin-prune-packed.c: use parse_options()Michele Ballabio, Jul 23, 2008
  13. 4/9 builtin-ls-tree.c: use parse_options()Michele Ballabio, Jul 23, 2008
  14. 5/9 builtin-rev-list.c: use parse_options()Michele Ballabio, Jul 23, 2008
  15. 6/9 builtin-init-db.c: use parse_options()Michele Ballabio, Jul 23, 2008
  16. Olivier MarinJul 24, 2008
  17. Johannes SchindelinJul 24, 2008
  18. Olivier MarinJul 25, 2008
  19. Johannes SchindelinJul 26, 2008
  20. Michele BallabioJul 24, 2008
  21. 6/9 builtin-init-db.c: use parse_options()Michele Ballabio, Jul 25, 2008
  22. Olivier MarinJul 25, 2008
  23. 6/9 builtin-init-db.c: use parse_options()Michele Ballabio, Jul 25, 2008
  24. 7/9 builtin-checkout-index.c: use parse_options()Michele Ballabio, Jul 23, 2008
  25. Johannes SchindelinJul 24, 2008
  26. Michele BallabioJul 24, 2008
  27. Sverre RabbelierJul 24, 2008
  28. René ScharfeJul 25, 2008
  29. 7/9 builtin-checkout-index.c: use parse_options()Michele Ballabio, Jul 25, 2008
  30. 8/9 builtin-fetch-pack.c: use parse_options()Michele Ballabio, Jul 23, 2008
  31. 9/9 builtin-mailinfo.c: use parse_options()Michele Ballabio, Jul 23, 2008

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.