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

[PATCH v3 1/6] credential-cache{,--daemon}: don't build under NO_UNIX_SOCKETS

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Sep 11, 2021, 19:09 UTC
Message-ID
<patch-v3-1.6-ad857e80fd8-20210911T190239Z-avarab@gmail.com>
In-Reply-To
<cover-v3-0.6-00000000000-20210911T190239Z-avarab@gmail.com>

Change the implementation of b5dd96b70ac (make credential helpers builtins, 2020-08-13) to not build these at all under NO_UNIX_SOCKETS.

This is the easiest way to get rid of one out of two users of an obscure parse_options() API I'm trying to get rid of. It does mean that the goal of emitting a custom error message in b5dd96b70ac is being eliminated, but per [1] that seems to be an OK direction to go in.

By not compiling it at all it won't be included in the "struct cmd_struct", and therefore will also be omitted from "--list-cmds=builtins".

1. https://lore.kernel.org/git/cover-v2-0.6-00000000000-20210910T153146Z-avarab@gmail.com/
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Makefile                           |  3 +++
 builtin.h                          |  2 ++
 builtin/credential-cache--daemon.c | 21 ---------------------
 builtin/credential-cache.c         | 21 ---------------------
 git.c                              |  2 ++
 5 files changed, 7 insertions(+), 42 deletions(-)
diff --git a/Makefile b/Makefile
index 429c276058d..ecde3367fa2 100644
--- a/Makefile
+++ b/Makefile
@@ -1086,8 +1086,10 @@ BUILTIN_OBJS += builtin/commit-tree.o
 BUILTIN_OBJS += builtin/commit.o
 BUILTIN_OBJS += builtin/config.o
 BUILTIN_OBJS += builtin/count-objects.o
+ifndef NO_UNIX_SOCKETS
 BUILTIN_OBJS += builtin/credential-cache--daemon.o
 BUILTIN_OBJS += builtin/credential-cache.o
+endif
 BUILTIN_OBJS += builtin/credential-store.o
 BUILTIN_OBJS += builtin/credential.o
 BUILTIN_OBJS += builtin/describe.o
@@ -1693,6 +1695,7 @@ ifdef NO_INET_PTON
 endif
 ifdef NO_UNIX_SOCKETS
 	BASIC_CFLAGS += -DNO_UNIX_SOCKETS
+	EXCLUDED_PROGRAMS += git-credential-cache git-credential-cache--daemon
 else
 	LIB_OBJS += unix-socket.o
 	LIB_OBJS += unix-stream-server.o
diff --git a/builtin.h b/builtin.h
index 16ecd5586f0..9b3f173bd7c 100644
--- a/builtin.h
+++ b/builtin.h
@@ -140,8 +140,10 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix);
 int cmd_config(int argc, const char **argv, const char *prefix);
 int cmd_count_objects(int argc, const char **argv, const char *prefix);
 int cmd_credential(int argc, const char **argv, const char *prefix);
+#ifndef NO_UNIX_SOCKETS
 int cmd_credential_cache(int argc, const char **argv, const char *prefix);
 int cmd_credential_cache_daemon(int argc, const char **argv, const char *prefix);
+#endif
 int cmd_credential_store(int argc, const char **argv, const char *prefix);
 int cmd_describe(int argc, const char **argv, const char *prefix);
 int cmd_diff_files(int argc, const char **argv, const char *prefix);
diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
index 4c6c89ab0de..7785412dea4 100644
--- a/builtin/credential-cache--daemon.c
+++ b/builtin/credential-cache--daemon.c
@@ -1,8 +1,5 @@
 #include "builtin.h"
 #include "parse-options.h"
-
-#ifndef NO_UNIX_SOCKETS
-
 #include "config.h"
 #include "tempfile.h"
 #include "credential.h"
@@ -299,21 +296,3 @@ int cmd_credential_cache_daemon(int argc, const char **argv, const char *prefix)
 
 	return 0;
 }
-
-#else
-
-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"));
-}
-
-#endif /* NO_UNIX_SOCKET */
diff --git a/builtin/credential-cache.c b/builtin/credential-cache.c
index e8a74157471..64942978650 100644
--- a/builtin/credential-cache.c
+++ b/builtin/credential-cache.c
@@ -1,8 +1,5 @@
 #include "builtin.h"
 #include "parse-options.h"
-
-#ifndef NO_UNIX_SOCKETS
-
 #include "credential.h"
 #include "string-list.h"
 #include "unix-socket.h"
@@ -137,21 +134,3 @@ int cmd_credential_cache(int argc, const char **argv, const char *prefix)
 
 	return 0;
 }
-
-#else
-
-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"));
-}
-
-#endif /* NO_UNIX_SOCKETS */
diff --git a/git.c b/git.c
index 18bed9a9964..7c696e06ecf 100644
--- a/git.c
+++ b/git.c
@@ -513,8 +513,10 @@ static struct cmd_struct commands[] = {
 	{ "config", cmd_config, RUN_SETUP_GENTLY | DELAY_PAGER_CONFIG },
 	{ "count-objects", cmd_count_objects, RUN_SETUP },
 	{ "credential", cmd_credential, RUN_SETUP_GENTLY | NO_PARSEOPT },
+#ifndef NO_UNIX_SOCKETS
 	{ "credential-cache", cmd_credential_cache },
 	{ "credential-cache--daemon", cmd_credential_cache_daemon },
+#endif
 	{ "credential-store", cmd_credential_store },
 	{ "describe", cmd_describe, RUN_SETUP },
 	{ "diff", cmd_diff, NO_PARSEOPT },
-- 
2.33.0.995.ga5ea46173a2
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 24 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.