Documentation/git-sh-setup.txt: programmer's docs
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index 4d6fad8879561ec86a5f37c06f129a19ae5c2f7d..7d858637c438f3938af3cf7a8d592cef1fa3bd43 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -837,7 +837,12 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
 
  retry:
        if (log && rename(git_path("tmp-renamed-log"), git_path("logs/%s", newref))) {
-               if (errno==EISDIR) {
+               if (errno==EISDIR || errno==ENOTDIR) {
+                       /*
+                        * rename(a, b) when b is an existing
+                        * directory ought to result in ISDIR, but
+                        * Solaris 5.8 gives ENOTDIR.  Sheesh.
+                        */
                        if (remove_empty_directories(git_path("logs/%s", newref))) {
                                error("Directory not empty: logs/%s", newref);
                                goto rollback;
@@ -923,6 +928,9 @@ static int log_ref_write(struct ref_lock *lock,
        char *logrec;
        const char *committer;
 
+       if (log_all_ref_updates < 0)
+               log_all_ref_updates = !is_bare_repository();
+
        if (log_all_ref_updates &&
            (!strncmp(lock->ref_name, "refs/heads/", 11) ||
             !strncmp(lock->ref_name, "refs/remotes/", 13))) {
@@ -1097,7 +1105,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
        return 0;
 }
 
-void for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
+int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
 {
        const char *logfile;
        FILE *logfp;
@@ -1106,19 +1114,35 @@ void for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
        logfile = git_path("logs/%s", ref);
        logfp = fopen(logfile, "r");
        if (!logfp)
-               return;
+               return -1;
        while (fgets(buf, sizeof(buf), logfp)) {
                unsigned char osha1[20], nsha1[20];
-               int len;
+               char *email_end, *message;
+               unsigned long timestamp;
+               int len, ret, tz;
 
                /* old SP new SP name <email> SP time TAB msg LF */
                len = strlen(buf);
                if (len < 83 || buf[len-1] != '\n' ||
                    get_sha1_hex(buf, osha1) || buf[40] != ' ' ||
-                   get_sha1_hex(buf + 41, nsha1) || buf[81] != ' ')
+                   get_sha1_hex(buf + 41, nsha1) || buf[81] != ' ' ||
+                   !(email_end = strchr(buf + 82, '>')) ||
+                   email_end[1] != ' ' ||
+                   !(timestamp = strtoul(email_end + 2, &message, 10)) ||
+                   !message || message[0] != ' ' ||
+                   (message[1] != '+' && message[1] != '-') ||
+                   !isdigit(message[2]) || !isdigit(message[3]) ||
+                   !isdigit(message[4]) || !isdigit(message[5]) ||
+                   message[6] != '\t')
                        continue; /* corrupt? */
-               fn(osha1, nsha1, buf+82, cb_data);
+               email_end[1] = '\0';
+               tz = strtol(message + 1, NULL, 10);
+               message += 7;
+               ret = fn(osha1, nsha1, buf+82, timestamp, tz, message, cb_data);
+               if (ret)
+                       return ret;
        }
        fclose(logfp);
+       return 0;
 }