[PATCH v3 1/6] credential-cache{,--daemon}: don't build under NO_UNIX_SOCKETS
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-09-11 19:10:34
Subsystem:
kernel build + files below scripts/ (unless maintained elsewhere), the rest · Maintainers:
Nathan Chancellor, Nicolas Schier, Linus Torvalds
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/ (local) Signed-off-by: Ævar Arnfjörð Bjarmason <redacted> --- 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