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

[PATCH][Outreachy] New git config variable to specify string that will be automatically passed as --push-option

From
TBThais D. Braz <thais.dinizbraz@gmail.com>
Date
Oct 11, 2017, 20:25 UTC
Message-ID
<20171011202505.10113-2-thais.dinizbraz@gmail.com>
In-Reply-To
<20171011202505.10113-1-thais.dinizbraz@gmail.com>
---
 Documentation/git-push.txt | 3 +++
 builtin/push.c             | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 3e76e99f3..e1036feaf 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -161,6 +161,9 @@ already exists on the remote side.
 	Transmit the given string to the server, which passes them to
 	the pre-receive as well as the post-receive hook. The given string
 	must not contain a NUL or LF character.
+	Can be configured using "git config push.optionDefault <option-string>".
+	After configured git push will always be executed silently
+	with --push-options <options configured>.
 
 --receive-pack=<git-receive-pack>::
 --exec=<git-receive-pack>::
diff --git a/builtin/push.c b/builtin/push.c
index 2ac810422..ae3efafce 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -467,11 +467,18 @@ static int git_push_config(const char *k, const char *v, void *cb)
 {
 	int *flags = cb;
 	int status;
+	struct string_list push_options = STRING_LIST_INIT_DUP;
 
 	status = git_gpg_config(k, v, NULL);
 	if (status)
 		return status;
 
+	const struct string_list *optionsDefault = git_config_get_value_multi("push.optionDefault");
+	for (int i = 0; i < optionsDefault->nr; i++) {
+		string_list_insert(&push_options, optionsDefault->items[i].string);
+	}
+
+
 	if (!strcmp(k, "push.followtags")) {
 		if (git_config_bool(k, v))
 			*flags |= TRANSPORT_PUSH_FOLLOW_TAGS;
@@ -515,7 +522,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 	int push_cert = -1;
 	int rc;
 	const char *repo = NULL;	/* default repository */
-	struct string_list push_options = STRING_LIST_INIT_DUP;
+	static struct string_list push_options = STRING_LIST_INIT_DUP;
 	const struct string_list_item *item;
 
 	struct option options[] = {
-- 
2.15.0.rc0.39.g2f0e14e.dirty
Previous: Thais D. BrazNext: Junio C Hamano
Message 16 of 24 in “Enhancement request: git-push: Allow (configurable) default push-option”
  1. Marius PaligaOct 3, 2017
  2. Stefan BellerOct 3, 2017
  3. Marius PaligaOct 4, 2017
  4. Marius PaligaOct 11, 2017
  5. Marius PaligaOct 11, 2017
  6. Stefan BellerOct 11, 2017
  7. Junio C HamanoOct 11, 2017
  8. Junio C HamanoOct 11, 2017
  9. Marius PaligaOct 12, 2017
  10. Marius PaligaOct 12, 2017
  11. Stefan BellerOct 12, 2017
  12. Junio C HamanoOct 13, 2017
  13. Junio C HamanoOct 13, 2017
  14. Marius PaligaOct 13, 2017
  15. Thais D. Braz, Oct 11, 2017
  16. [Outreachy] New git config variable to specify string that will be automatically passed as --push-optionThais D. Braz, Oct 11, 2017
  17. Junio C HamanoOct 12, 2017
  18. Christian CouderOct 12, 2017
  19. Junio C HamanoOct 12, 2017
  20. patch replyThais Diniz, Oct 17, 2017
  21. Junio C HamanoOct 17, 2017
  22. Marius PaligaOct 17, 2017
  23. thais brazOct 17, 2017
  24. [Outreachy] New git config variable to specify string that will be automatically passed as --push-optionThais D. Braz, Oct 11, 2017

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.