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

Re: [PATCH v2 2/6] git.c: add a NEED_UNIX_SOCKETS option for built-ins

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 11, 2021, 00:14 UTC
Message-ID
<xmqqr1dwotmn.fsf@gitster.g>
In-Reply-To
<patch-v2-2.6-d6c44402715-20210910T153147Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
> Change the implementation of b5dd96b70ac (make credential helpers
> builtins, 2020-08-13) to declare in the "struct cmd_struct" that
> NO_UNIX_SOCKETS can't be set.

It may happen to be that two credential-cache program are both related to the same CPP macro NO_UNIX_SOCKETS, but I think the pattern you are tackling with this topic is that a fallback definition of a function that is designed to always die when invoked misuses the parse-options API. I do not want to see you invent a new bit in cmd_struct for each and every conditional that lets us define such a die-only fallback implementation.

I may be missing something obvious, but can't the following suffice, and if not, why?

Thanks.
 builtin/credential-cache--daemon.c | 9 ---------
 builtin/credential-cache.c         | 9 ---------
 2 files changed, 18 deletions(-)
diff --git i/builtin/credential-cache--daemon.c w/builtin/credential-cache--daemon.c
index 4c6c89ab0d..f11a89a89b 100644
--- i/builtin/credential-cache--daemon.c
+++ w/builtin/credential-cache--daemon.c
@@ -304,15 +304,6 @@ int cmd_credential_cache_daemon(int argc, const char **argv, const char *prefix)
 
 int cmd_credential_cache_daemon(int argc, const char **argv, const char *prefix)
 {
-	const char * const usage[] = {
-		"git credential-cache--daemon [options] <action>",
-		"",
-		"credential-cache--daemon is disabled in this build of Git",
-		NULL
-	};
-	struct option options[] = { OPT_END() };
-
-	argc = parse_options(argc, argv, prefix, options, usage, 0);
 	die(_("credential-cache--daemon unavailable; no unix socket support"));
 }
 
diff --git i/builtin/credential-cache.c w/builtin/credential-cache.c
index e8a7415747..dd794f84ce 100644
--- i/builtin/credential-cache.c
+++ w/builtin/credential-cache.c
@@ -142,15 +142,6 @@ int cmd_credential_cache(int argc, const char **argv, const char *prefix)
 
 int cmd_credential_cache(int argc, const char **argv, const char *prefix)
 {
-	const char * const usage[] = {
-		"git credential-cache [options] <action>",
-		"",
-		"credential-cache is disabled in this build of Git",
-		NULL
-	};
-	struct option options[] = { OPT_END() };
-
-	argc = parse_options(argc, argv, prefix, options, usage, 0);
 	die(_("credential-cache unavailable; no unix socket support"));
 }
 
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 8 of 45 in “parse-options: properly align continued usage output”
  1. 0/2 parse-options: properly align continued usage outputÆvar Arnfjörð Bjarmason, Sep 1, 2021
  2. 1/2 built-ins: "properly" align continued usage outputÆvar Arnfjörð Bjarmason, Sep 1, 2021
  3. 2/2 parse-options: properly align continued usage outputÆvar Arnfjörð Bjarmason, Sep 1, 2021
  4. Eric SunshineSep 10, 2021
  5. 0/6 parse-options: properly align continued usage output & relatedÆvar Arnfjörð Bjarmason, Sep 10, 2021
  6. 1/6 test-lib.sh: add a UNIX_SOCKETS prerequisiteÆvar Arnfjörð Bjarmason, Sep 10, 2021
  7. 2/6 git.c: add a NEED_UNIX_SOCKETS option for built-insÆvar Arnfjörð Bjarmason, Sep 10, 2021
  8. Junio C HamanoSep 11, 2021
  9. Ævar Arnfjörð BjarmasonSep 11, 2021
  10. Carlo Marcelo Arenas BelónSep 11, 2021
  11. Junio C HamanoSep 11, 2021
  12. Ævar Arnfjörð BjarmasonSep 11, 2021
  13. 3/6 parse-options: stop supporting "" in the usagestr arrayÆvar Arnfjörð Bjarmason, Sep 10, 2021
  14. Junio C HamanoSep 11, 2021
  15. Ævar Arnfjörð BjarmasonSep 11, 2021
  16. Junio C HamanoSep 11, 2021
  17. 4/6 built-ins: "properly" align continued usage outputÆvar Arnfjörð Bjarmason, Sep 10, 2021
  18. Junio C HamanoSep 11, 2021
  19. Ævar Arnfjörð BjarmasonSep 11, 2021
  20. 5/6 send-pack: properly use parse_options() API for usage stringÆvar Arnfjörð Bjarmason, Sep 10, 2021
  21. 6/6 parse-options: properly align continued usage outputÆvar Arnfjörð Bjarmason, Sep 10, 2021
  22. Eric SunshineSep 11, 2021
  23. 0/6 parse-options: properly align continued usage output & relatedÆvar Arnfjörð Bjarmason, Sep 11, 2021
  24. 1/6 credential-cache{,--daemon}: don't build under NO_UNIX_SOCKETSÆvar Arnfjörð Bjarmason, Sep 11, 2021
  25. Junio C HamanoSep 12, 2021
  26. 2/6 blame: replace usage end blurb with better option specÆvar Arnfjörð Bjarmason, Sep 11, 2021
  27. Eric SunshineSep 12, 2021
  28. Junio C HamanoSep 12, 2021
  29. 3/6 parse-options: stop supporting "" in the usagestr arrayÆvar Arnfjörð Bjarmason, Sep 11, 2021
  30. Junio C HamanoSep 12, 2021
  31. Ævar Arnfjörð BjarmasonSep 13, 2021
  32. 4/6 built-ins: "properly" align continued usage outputÆvar Arnfjörð Bjarmason, Sep 11, 2021
  33. 5/6 send-pack: properly use parse_options() API for usage stringÆvar Arnfjörð Bjarmason, Sep 11, 2021
  34. 6/6 parse-options: properly align continued usage outputÆvar Arnfjörð Bjarmason, Sep 11, 2021
  35. 0/4 parse-options: properly align continued usage outputÆvar Arnfjörð Bjarmason, Sep 13, 2021
  36. 1/4 parse-options API users: align usage output in C-stringsÆvar Arnfjörð Bjarmason, Sep 13, 2021
  37. 2/4 send-pack: properly use parse_options() API for usage stringÆvar Arnfjörð Bjarmason, Sep 13, 2021
  38. 3/4 git rev-parse --parseopt tests: add more usagestr testsÆvar Arnfjörð Bjarmason, Sep 13, 2021
  39. 4/4 parse-options: properly align continued usage outputÆvar Arnfjörð Bjarmason, Sep 13, 2021
  40. Junio C HamanoSep 13, 2021
  41. 0/4 parse-options: properly align continued usage outputÆvar Arnfjörð Bjarmason, Sep 21, 2021
  42. 2/4 send-pack: properly use parse_options() API for usage stringÆvar Arnfjörð Bjarmason, Sep 21, 2021
  43. 3/4 git rev-parse --parseopt tests: add more usagestr testsÆvar Arnfjörð Bjarmason, Sep 21, 2021
  44. 4/4 parse-options: properly align continued usage outputÆvar Arnfjörð Bjarmason, Sep 21, 2021
  45. 1/4 parse-options API users: align usage output in C-stringsÆvar Arnfjörð Bjarmason, Sep 21, 2021

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.