Skip to content

Commit 9e5b80c

Browse files
committed
Squelch overzealous "ignoring dangling symref" in an empty repository
057e713 (Warn use of "origin" when remotes/origin/HEAD is dangling, 2009-02-08) tried to warn dangling refs/remotes/origin/HEAD only when "origin" was used to refer to it. There was one corner case a symref is expected to be dangling and this warning is unwarranted: HEAD in an empty repository. This squelches the warning for this special case. Signed-off-by: Junio C Hamano <[email protected]>
1 parent aff4e8d commit 9e5b80c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sha1_name.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
278278
*ref = xstrdup(r);
279279
if (!warn_ambiguous_refs)
280280
break;
281-
} else if (flag & REF_ISSYMREF)
281+
} else if ((flag & REF_ISSYMREF) &&
282+
(len != 4 || strcmp(str, "HEAD")))
282283
warning("ignoring dangling symref %s.", fullref);
283284
}
284285
free(last_branch);

0 commit comments

Comments
 (0)