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

[PATCH] "git-push $URL" without refspecs pushes only matching branches

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 2, 2007, 02:00 UTC
Message-ID
<7v7ipj1s5z.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<7vk5u9hzv9.fsf@assigned-by-dhcp.pobox.com>

When "git push" is run without any refspec (neither on the command line nor in the config), we used to push "matching refs" in the sense that anything under refs/ hierarchy that exist on both ends were updated. This used to be a sane default for publishing your repository to another back when we did not have refs/remotes/ hierarchy, but it does not make much sense these days.

This changes the semantics to push only "matching branches".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Junio C Hamano <gitster@pobox.com> writes:
 > Probably we should not do push anything other than refs/heads/
 > when we do "matching refs"
 >
 > I think what we might want to do around this area are:
 >
 >  - Don't change anything, if the command line says refspec, or
 >    the remote has push refspec specified.
 >
 >  - When doing 'matching refs', do it only under refs/heads/.
 >
 >  - Ship with a receive-pack hook that attempts a 3-way merge
 >    update when the currently checked out branch is updated.
 >
 > Additionally we can give an option to "git clone" (or "git
 > remote add") to arrange the cross-push configuration for
 > mothership-satellite Andy showed in the clone's .git/config;
 > but I think that is a separate issue.
 remote.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/remote.c b/remote.c
index 500ca4d..cf98a44 100644
--- a/remote.c
+++ b/remote.c
@@ -544,6 +544,13 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
 			if (!pat)
 				continue;
 		}
+		else if (prefixcmp(src->name, "refs/heads/"))
+			/*
+			 * "matching refs"; traditionally we pushed everything
+			 * including refs outside refs/heads/ hierarchy, but
+			 * that does not make much sense these days.
+			 */
+			continue;
 
 		if (pat) {
 			const char *dst_side = pat->dst ? pat->dst : pat->src;
Previous: Martin Langhoff
Message 15 of 15 in “Problem with a push”
  1. Alex R.M. TurnerJun 11, 2007
  2. Linus TorvaldsJun 11, 2007
  3. Alex R.M. TurnerJun 11, 2007
  4. Linus TorvaldsJun 12, 2007
  5. Junio C HamanoJun 12, 2007
  6. Alex R.M. TurnerJun 12, 2007
  7. Linus TorvaldsJun 12, 2007
  8. Jon LoeligerJun 12, 2007
  9. Junio C HamanoJun 11, 2007
  10. Andy ParkinsJun 12, 2007
  11. Linus TorvaldsJun 12, 2007
  12. Junio C HamanoJun 12, 2007
  13. Linus TorvaldsJun 12, 2007
  14. Martin LanghoffJun 12, 2007
  15. "git-push $URL" without refspecs pushes only matching branchesJunio C Hamano, Jul 2, 2007

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.