summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 416a673..01b36ea 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -517,12 +517,21 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
}
if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
&co_time, &co_tz, &co_cnt)) {
+ if (!len) {
+ if (!prefixcmp(real_ref, "refs/heads/")) {
+ str = real_ref + 11;
+ len = strlen(real_ref + 11);
+ } else {
+ /* detached HEAD */
+ str = "HEAD";
+ len = 4;
+ }
+ }
if (at_time)
warning("Log for '%.*s' only goes "
"back to %s.", len, str,
show_date(co_time, co_tz, DATE_RFC2822));
else {
- free(real_ref);
die("Log for '%.*s' only has %d entries.",
len, str, co_cnt);
}