summaryrefslogtreecommitdiff
path: root/refspec.c
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2020-11-26 00:16:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-11-30 21:57:55 (GMT)
commit374fbaef3df8f05acf9968fc38c6da72a62bcfc2 (patch)
tree13cca8b260b1ddeee0d3901a452a784cc13aa7be /refspec.c
parente7f80eafd1be8c6771ef3e1e389853e18ed7e90b (diff)
downloadgit-374fbaef3df8f05acf9968fc38c6da72a62bcfc2.zip
git-374fbaef3df8f05acf9968fc38c6da72a62bcfc2.tar.gz
git-374fbaef3df8f05acf9968fc38c6da72a62bcfc2.tar.bz2
refspec: make @ a synonym of HEAD
Since commit 9ba89f484e git learned how to push to a remote branch using the source @, for example: git push origin @:master However, if the right-hand side is missing, the push fails: git push origin @ It is obvious what is the desired behavior, and allowing the push makes things more consistent. Additionally, @:master now has the same semantics as HEAD:master. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refspec.c')
-rw-r--r--refspec.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/refspec.c b/refspec.c
index c49347c..adbfb32 100644
--- a/refspec.c
+++ b/refspec.c
@@ -71,7 +71,10 @@ static int parse_refspec(struct refspec_item *item, const char *refspec, int fet
}
item->pattern = is_glob;
- item->src = xstrndup(lhs, llen);
+ if (llen == 1 && *lhs == '@')
+ item->src = xstrdup("HEAD");
+ else
+ item->src = xstrndup(lhs, llen);
flags = REFNAME_ALLOW_ONELEVEL | (is_glob ? REFNAME_REFSPEC_PATTERN : 0);
if (item->negative) {