[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;