All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
	"Carlo Arenas" <carenas@gmail.com>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v3 1/6] credential-cache{,--daemon}: don't build under NO_UNIX_SOCKETS
Date: Sat, 11 Sep 2021 21:09:00 +0200	[thread overview]
Message-ID: <patch-v3-1.6-ad857e80fd8-20210911T190239Z-avarab@gmail.com> (raw)
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


  reply	other threads:[~2021-09-11 19:10 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01 11:12 [PATCH 0/2] parse-options: properly align continued usage output Ævar Arnfjörð Bjarmason
2021-09-01 11:12 ` [PATCH 1/2] built-ins: "properly" " Ævar Arnfjörð Bjarmason
2021-09-01 11:12 ` [PATCH 2/2] parse-options: properly " Ævar Arnfjörð Bjarmason
2021-09-10  7:51   ` Eric Sunshine
2021-09-10 15:38 ` [PATCH v2 0/6] parse-options: properly align continued usage output & related Ævar Arnfjörð Bjarmason
2021-09-10 15:38   ` [PATCH v2 1/6] test-lib.sh: add a UNIX_SOCKETS prerequisite Ævar Arnfjörð Bjarmason
2021-09-10 15:38   ` [PATCH v2 2/6] git.c: add a NEED_UNIX_SOCKETS option for built-ins Ævar Arnfjörð Bjarmason
2021-09-11  0:14     ` Junio C Hamano
2021-09-11  2:50       ` Ævar Arnfjörð Bjarmason
2021-09-11  3:47         ` Carlo Marcelo Arenas Belón
2021-09-11  6:12           ` Junio C Hamano
2021-09-11  7:16           ` Ævar Arnfjörð Bjarmason
2021-09-10 15:38   ` [PATCH v2 3/6] parse-options: stop supporting "" in the usagestr array Ævar Arnfjörð Bjarmason
2021-09-11  0:21     ` Junio C Hamano
2021-09-11  2:46       ` Ævar Arnfjörð Bjarmason
2021-09-11  6:52         ` Junio C Hamano
2021-09-10 15:38   ` [PATCH v2 4/6] built-ins: "properly" align continued usage output Ævar Arnfjörð Bjarmason
2021-09-11  0:25     ` Junio C Hamano
2021-09-11  2:40       ` Ævar Arnfjörð Bjarmason
2021-09-10 15:38   ` [PATCH v2 5/6] send-pack: properly use parse_options() API for usage string Ævar Arnfjörð Bjarmason
2021-09-10 15:38   ` [PATCH v2 6/6] parse-options: properly align continued usage output Ævar Arnfjörð Bjarmason
2021-09-11  7:41   ` [PATCH v2 0/6] parse-options: properly align continued usage output & related Eric Sunshine
2021-09-11 19:08   ` [PATCH v3 " Ævar Arnfjörð Bjarmason
2021-09-11 19:09     ` Ævar Arnfjörð Bjarmason [this message]
2021-09-12 21:48       ` [PATCH v3 1/6] credential-cache{,--daemon}: don't build under NO_UNIX_SOCKETS Junio C Hamano
2021-09-11 19:09     ` [PATCH v3 2/6] blame: replace usage end blurb with better option spec Ævar Arnfjörð Bjarmason
2021-09-12  4:45       ` Eric Sunshine
2021-09-12 22:22       ` Junio C Hamano
2021-09-11 19:09     ` [PATCH v3 3/6] parse-options: stop supporting "" in the usagestr array Ævar Arnfjörð Bjarmason
2021-09-12 22:26       ` Junio C Hamano
2021-09-13  0:21         ` Ævar Arnfjörð Bjarmason
2021-09-11 19:09     ` [PATCH v3 4/6] built-ins: "properly" align continued usage output Ævar Arnfjörð Bjarmason
2021-09-11 19:09     ` [PATCH v3 5/6] send-pack: properly use parse_options() API for usage string Ævar Arnfjörð Bjarmason
2021-09-11 19:09     ` [PATCH v3 6/6] parse-options: properly align continued usage output Ævar Arnfjörð Bjarmason
2021-09-13  0:13     ` [PATCH v4 0/4] " Ævar Arnfjörð Bjarmason
2021-09-13  0:13       ` [PATCH v4 1/4] parse-options API users: align usage output in C-strings Ævar Arnfjörð Bjarmason
2021-09-13  0:13       ` [PATCH v4 2/4] send-pack: properly use parse_options() API for usage string Ævar Arnfjörð Bjarmason
2021-09-13  0:13       ` [PATCH v4 3/4] git rev-parse --parseopt tests: add more usagestr tests Ævar Arnfjörð Bjarmason
2021-09-13  0:13       ` [PATCH v4 4/4] parse-options: properly align continued usage output Ævar Arnfjörð Bjarmason
2021-09-13  6:41         ` Junio C Hamano
2021-09-21 13:30       ` [PATCH v5 0/4] " Ævar Arnfjörð Bjarmason
2021-09-21 13:30         ` [PATCH v5 1/4] parse-options API users: align usage output in C-strings Ævar Arnfjörð Bjarmason
2021-09-21 13:30         ` [PATCH v5 2/4] send-pack: properly use parse_options() API for usage string Ævar Arnfjörð Bjarmason
2021-09-21 13:30         ` [PATCH v5 3/4] git rev-parse --parseopt tests: add more usagestr tests Ævar Arnfjörð Bjarmason
2021-09-21 13:30         ` [PATCH v5 4/4] parse-options: properly align continued usage output Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=patch-v3-1.6-ad857e80fd8-20210911T190239Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.