]> git.ipfire.org Git - thirdparty/git.git/blobdiff - refspec.c
Merge branch 'ab/pager-exit-log'
[thirdparty/git.git] / refspec.c
index c49347c2d7b78221324bdf76b5760eaab6ecf2ad..e3d852c0bfeca6bd5d166e5c8041d8176eae3a11 100644 (file)
--- 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) {
@@ -272,15 +275,16 @@ void refspec_ref_prefixes(const struct refspec *rs,
                else if (item->src && !item->exact_sha1)
                        prefix = item->src;
 
-               if (prefix) {
-                       if (item->pattern) {
-                               const char *glob = strchr(prefix, '*');
-                               strvec_pushf(ref_prefixes, "%.*s",
-                                            (int)(glob - prefix),
-                                            prefix);
-                       } else {
-                               expand_ref_prefix(ref_prefixes, prefix);
-                       }
+               if (!prefix)
+                       continue;
+
+               if (item->pattern) {
+                       const char *glob = strchr(prefix, '*');
+                       strvec_pushf(ref_prefixes, "%.*s",
+                                    (int)(glob - prefix),
+                                    prefix);
+               } else {
+                       expand_ref_prefix(ref_prefixes, prefix);
                }
        }
 }