Fix an "implicit function definition" warning.
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index 03e8dfec9fcb2c9fffc7c809048fa90a0e02b0af..a9b8c72c6b6ea017f36639f01c997275299b16ad 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);
@@ -1039,7 +1042,9 @@ int create_symref(const char *ref_target, const char *refs_heads_master,
                return -1;
        }
 
+#ifndef NO_SYMLINK_HEAD
        done:
+#endif
        if (logmsg && !read_ref(refs_heads_master, new_sha1))
                log_ref_write(ref_target, old_sha1, new_sha1, logmsg);
 
@@ -1189,12 +1194,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 +1213,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 +1253,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;
 }