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

[PATCH] push: start warning upcoming default change for push.default

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Jun 24, 2012, 11:01 UTC
Message-ID
<1340535697-14556-1-git-send-email-Matthieu.Moy@imag.fr>
In-Reply-To
<7v7guzqluh.fsf@alter.siamese.dyndns.org>

In preparation for flipping the default to the "simple" mode from the "matching" mode that is the historical default, start warning users when they rely on unconfigured "git push" to default to the "matching" mode.

Also, advertise for 'simple' where 'current' and 'upstream' are advised.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
>>   (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
>>   'current' instead of 'simple' if you sometimes use older versions of Git)
>
> Yeah, that would work (the minority that need to pick 'current'
> cannot cut and paste, but that is not a big deal).
>
> As I did not butcher the version you sent me when I queued it with
> my rewrite, a follow-up patch to update it should be fairly minimal
> ;-)
Here it is.
 builtin/push.c       | 29 +++++++++++++++++++++++++++--
 t/t5541-http-push.sh |  5 ++++-
 2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/builtin/push.c b/builtin/push.c
index 08ccb89..9a0a035 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -147,12 +147,37 @@ static void setup_push_upstream(struct remote *remote, int simple)
 	add_refspec(refspec.buf);
 }
 
+static char warn_unspecified_push_default_msg[] =
+N_("push.default is unset; its implicit value is changing in\n"
+   "Git 2.0 from 'matching' to 'simple'. To squelch this message\n"
+   "and maintain the current behavior after the default changes, use:\n"
+   "\n"
+   "  git config --global push.default matching\n"
+   "\n"
+   "To squelch this message and adopt the new behavior now, use:\n"
+   "\n"
+   "  git config --global push.default simple\n"
+   "\n"
+   "See 'git help config' and search for 'push.default' for further information.\n"
+   "(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode\n"
+   "'current' instead of 'simple' if you sometimes use older versions of Git)");
+
+static void warn_unspecified_push_default_configuration(void)
+{
+	static int warn_once;
+
+	if (warn_once++)
+		return;
+	warning("%s\n", _(warn_unspecified_push_default_msg));
+}
+
 static void setup_default_push_refspecs(struct remote *remote)
 {
 	switch (push_default) {
 	default:
 	case PUSH_DEFAULT_UNSPECIFIED:
 		default_matching_used = 1;
+		warn_unspecified_push_default_configuration();
 		/* fallthru */
 	case PUSH_DEFAULT_MATCHING:
 		add_refspec(":");
@@ -186,8 +211,8 @@ static const char message_advice_pull_before_push[] =
 static const char message_advice_use_upstream[] =
 	N_("Updates were rejected because a pushed branch tip is behind its remote\n"
 	   "counterpart. If you did not intend to push that branch, you may want to\n"
-	   "specify branches to push or set the 'push.default' configuration\n"
-	   "variable to 'current' or 'upstream' to push only the current branch.");
+	   "specify branches to push or set the 'push.default' configuration variable\n"
+	   "to 'simple', 'current' or 'upstream' to push only the current branch.");
 
 static const char message_advice_checkout_pull_push[] =
 	N_("Updates were rejected because a pushed branch tip is behind its remote\n"
diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh
index 5b170be..07fa199 100755
--- a/t/t5541-http-push.sh
+++ b/t/t5541-http-push.sh
@@ -64,7 +64,10 @@ test_expect_success 'no empty path components' '
 
 test_expect_success 'clone remote repository' '
 	rm -rf test_repo_clone &&
-	git clone $HTTPD_URL/smart/test_repo.git test_repo_clone
+	git clone $HTTPD_URL/smart/test_repo.git test_repo_clone &&
+	(
+		cd test_repo_clone && git config push.default matching
+	)
 '
 
 test_expect_success 'push to remote repository (standard)' '
-- 
1.7.11.5.g0c7e058.dirty
Previous: Junio C Hamano
Message 15 of 15 in “What's cooking in git.git (Jun 2012, #05; Tue, 19)”
  1. Junio C HamanoJun 19, 2012
  2. push: start warning upcoming default change for push.defaultMatthieu Moy, Jun 20, 2012
  3. Junio C HamanoJun 20, 2012
  4. Matthieu MoyJun 20, 2012
  5. Junio C HamanoJun 20, 2012
  6. Matthieu MoyJun 20, 2012
  7. Junio C HamanoJun 20, 2012
  8. Matthieu MoyJun 21, 2012
  9. Junio C HamanoJun 21, 2012
  10. Matthieu MoyJun 21, 2012
  11. Junio C HamanoJun 21, 2012
  12. Junio C HamanoJun 21, 2012
  13. Matthieu MoyJun 22, 2012
  14. Junio C HamanoJun 22, 2012
  15. push: start warning upcoming default change for push.defaultMatthieu Moy, Jun 24, 2012

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.