Still updating 1.5.0 release notes.
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index 03e8dfec9fcb2c9fffc7c809048fa90a0e02b0af..63877037893603c385e63547c83ea8c59f7c3101 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1000,6 +1000,9 @@ int create_symref(const char *ref_target, const char *refs_heads_master,
        if (logmsg && read_ref(ref_target, old_sha1))
                hashclr(old_sha1);
 
+       if (safe_create_leading_directories(git_HEAD) < 0)
+               return error("unable to create directory for %s", git_HEAD);
+
 #ifndef NO_SYMLINK_HEAD
        if (prefer_symlink_refs) {
                unlink(git_HEAD);
@@ -1189,12 +1192,14 @@ int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
                    !message || message[0] != ' ' ||
                    (message[1] != '+' && message[1] != '-') ||
                    !isdigit(message[2]) || !isdigit(message[3]) ||
-                   !isdigit(message[4]) || !isdigit(message[5]) ||
-                   message[6] != '\t')
+                   !isdigit(message[4]) || !isdigit(message[5]))
                        continue; /* corrupt? */
                email_end[1] = '\0';
                tz = strtol(message + 1, NULL, 10);
-               message += 7;
+               if (message[6] != '\t')
+                       message += 6;
+               else
+                       message += 7;
                ret = fn(osha1, nsha1, buf+82, timestamp, tz, message, cb_data);
                if (ret)
                        break;
@@ -1206,7 +1211,7 @@ int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
 static int do_for_each_reflog(const char *base, each_ref_fn fn, void *cb_data)
 {
        DIR *dir = opendir(git_path("logs/%s", base));
-       int retval = errno;
+       int retval = 0;
 
        if (dir) {
                struct dirent *de;
@@ -1246,6 +1251,8 @@ static int do_for_each_reflog(const char *base, each_ref_fn fn, void *cb_data)
                free(log);
                closedir(dir);
        }
+       else if (*base)
+               return errno;
        return retval;
 }