summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2010-02-16 02:03:16 -0500
committerJunio C Hamano <gitster@pobox.com>2010-02-16 09:03:58 -0800
commit003c6abdb27c367747847a76b0a7890d67c794be (patch)
treec4410379462761a7cac69246521f806d31deac0c /sha1_name.c
parent460ccd0e19774fd5e4f69de5a454068c686ac5a6 (diff)
downloadgit-003c6abdb27c367747847a76b0a7890d67c794be.tar.gz
dwim_ref: fix dangling symref warning
If we encounter a symref that is dangling, in most cases we will warn about it. The one exception is a dangling HEAD, as that indicates a branch yet to be born. However, the check in dwim_ref was not quite right. If we were fed something like "HEAD^0" we would try to resolve "HEAD", see that it is dangling, and then check whether the _original_ string we got was "HEAD" (which it wasn't in this case). And that makes no sense; the dangling thing we found was not "HEAD^0" but rather "HEAD". Fixing this squelches a scary warning from "submodule summary HEAD" (and consequently "git status" with status.submodulesummary set) in an empty repo, as the submodule script calls "git rev-parse -q --verify HEAD^0". Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 44bb62d270..9677afdadb 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -278,8 +278,7 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
*ref = xstrdup(r);
if (!warn_ambiguous_refs)
break;
- } else if ((flag & REF_ISSYMREF) &&
- (len != 4 || strcmp(str, "HEAD")))
+ } else if ((flag & REF_ISSYMREF) && strcmp(fullref, "HEAD"))
warning("ignoring dangling symref %s.", fullref);
}
free(last_branch);