git-svn: add support for --stat in the log command
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index f3579457ce91e87af42eb6cb68aa791b91d66193..d347876c876cfe210896a1f31d2b073849271f28 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -828,8 +828,8 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
                goto rollback;
        }
 
-       if (!strncmp(oldref, "refs/heads/", 11) &&
-                       !strncmp(newref, "refs/heads/", 11)) {
+       if (!prefixcmp(oldref, "refs/heads/") &&
+                       !prefixcmp(newref, "refs/heads/")) {
                char oldsection[1024], newsection[1024];
 
                snprintf(oldsection, 1024, "branch.%s", oldref + 11);
@@ -894,8 +894,8 @@ static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
        log_file = git_path("logs/%s", ref_name);
 
        if (log_all_ref_updates &&
-           (!strncmp(ref_name, "refs/heads/", 11) ||
-            !strncmp(ref_name, "refs/remotes/", 13) ||
+           (!prefixcmp(ref_name, "refs/heads/") ||
+            !prefixcmp(ref_name, "refs/remotes/") ||
             !strcmp(ref_name, "HEAD"))) {
                if (safe_create_leading_directories(log_file) < 0)
                        return error("unable to create directory for %s",
@@ -1192,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;
@@ -1249,7 +1251,7 @@ static int do_for_each_reflog(const char *base, each_ref_fn fn, void *cb_data)
                free(log);
                closedir(dir);
        }
-       else
+       else if (*base)
                return errno;
        return retval;
 }