From 9f0ea7e8283da126c8e1d5e0c3b39c39200258ad Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Wed, 20 Feb 2008 12:54:05 -0500 Subject: Resolve value supplied for no-colon push refspecs When pushing a refspec like "HEAD", we used to treat it as "HEAD:HEAD", which didn't work without rewriting. Instead, we should resolve the ref. If it's a symref, further require it to point to a branch, to avoid doing anything especially unexpected. Also remove the rewriting previously added in builtin-push. Since the code for "HEAD" uses the regular refspec parsing, it automatically handles "+HEAD" without anything special. [jc: added a further test to make sure that "remote.*.push = HEAD" works] Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- remote.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'remote.c') diff --git a/remote.c b/remote.c index 6b56473f5b..8ee2487ed3 100644 --- a/remote.c +++ b/remote.c @@ -643,9 +643,17 @@ static int match_explicit(struct ref *src, struct ref *dst, errs = 1; if (!dst_value) { + unsigned char sha1[20]; + int flag; + if (!matched_src) return errs; - dst_value = matched_src->name; + dst_value = resolve_ref(matched_src->name, sha1, 1, &flag); + if (!dst_value || + ((flag & REF_ISSYMREF) && + prefixcmp(dst_value, "refs/heads/"))) + die("%s cannot be resolved to branch.", + matched_src->name); } switch (count_refspec_match(dst_value, dst, &matched_dst)) { -- cgit v1.2.3