commit: add short-circuit to paint_down_to_common()
[gitweb.git] / rerere.c
index f0b4bce881963b8e757354f8a022d09e239dcc81..79203c6c1eae0db5515030b138e9e40e219af5f5 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -159,8 +159,8 @@ static struct rerere_dir *find_rerere_dir(const char *hex)
                ALLOC_GROW(rerere_dir, rerere_dir_nr + 1, rerere_dir_alloc);
                /* ... and add it in. */
                rerere_dir_nr++;
-               memmove(rerere_dir + pos + 1, rerere_dir + pos,
-                       (rerere_dir_nr - pos - 1) * sizeof(*rerere_dir));
+               MOVE_ARRAY(rerere_dir + pos + 1, rerere_dir + pos,
+                          rerere_dir_nr - pos - 1);
                rerere_dir[pos] = rr_dir;
                scan_rerere_dir(rr_dir);
        }
@@ -258,7 +258,7 @@ static int write_rr(struct string_list *rr, int out_fd)
                                    rerere_id_hex(id),
                                    rr->items[i].string, 0);
 
-               if (write_in_full(out_fd, buf.buf, buf.len) != buf.len)
+               if (write_in_full(out_fd, buf.buf, buf.len) < 0)
                        die("unable to write rerere record");
 
                strbuf_release(&buf);
@@ -1176,16 +1176,6 @@ static void prune_one(struct rerere_id *id,
                unlink_rr_item(id);
 }
 
-static void config_get_expiry(const char *key, timestamp_t *cutoff, timestamp_t now)
-{
-       int days;
-
-       if (!git_config_get_int(key, &days)) {
-               const int scale = 86400;
-               *cutoff = now - days * scale;
-       }
-}
-
 void rerere_gc(struct string_list *rr)
 {
        struct string_list to_remove = STRING_LIST_INIT_DUP;
@@ -1199,8 +1189,8 @@ void rerere_gc(struct string_list *rr)
        if (setup_rerere(rr, 0) < 0)
                return;
 
-       config_get_expiry("gc.rerereresolved", &cutoff_resolve, now);
-       config_get_expiry("gc.rerereunresolved", &cutoff_noresolve, now);
+       git_config_get_expiry_in_days("gc.rerereresolved", &cutoff_resolve, now);
+       git_config_get_expiry_in_days("gc.rerereunresolved", &cutoff_noresolve, now);
        git_config(git_default_config, NULL);
        dir = opendir(git_path("rr-cache"));
        if (!dir)