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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 Junio C Hamano <gitster@xxxxxxxxx> 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;

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux