Code

Introduce the config variable pack.packSizeLimit
[git.git] / builtin-rerere.c
index b8206744c12307b3efbdebc99e5bcdd4a8632212..a9e3ebc13725cbe8658478797d6e1d8e097e5292 100644 (file)
@@ -61,9 +61,9 @@ static int write_rr(struct path_list *rr, int out_fd)
                    write_in_full(out_fd, path, length) != length)
                        die("unable to write rerere record");
        }
-       if (close(out_fd) != 0)
+       if (commit_lock_file(&write_lock) != 0)
                die("unable to write rerere record");
-       return commit_lock_file(&write_lock);
+       return 0;
 }
 
 static int handle_file(const char *path,
@@ -260,7 +260,7 @@ static int diff_two(const char *file1, const char *label1,
        memset(&xecfg, 0, sizeof(xecfg));
        xecfg.ctxlen = 3;
        ecb.outf = outf;
-       xdl_diff(&minus, &plus, &xpp, &xecfg, &ecb);
+       xdi_diff(&minus, &plus, &xpp, &xecfg, &ecb);
 
        free(minus.ptr);
        free(plus.ptr);
@@ -389,18 +389,39 @@ static int is_rerere_enabled(void)
        return 1;
 }
 
-int cmd_rerere(int argc, const char **argv, const char *prefix)
+static int setup_rerere(struct path_list *merge_rr)
 {
-       struct path_list merge_rr = { NULL, 0, 0, 1 };
-       int i, fd = -1;
+       int fd;
 
        git_config(git_rerere_config);
        if (!is_rerere_enabled())
-               return 0;
+               return -1;
 
        merge_rr_path = xstrdup(git_path("rr-cache/MERGE_RR"));
        fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);
-       read_rr(&merge_rr);
+       read_rr(merge_rr);
+       return fd;
+}
+
+int rerere(void)
+{
+       struct path_list merge_rr = { NULL, 0, 0, 1 };
+       int fd;
+
+       fd = setup_rerere(&merge_rr);
+       if (fd < 0)
+               return 0;
+       return do_plain_rerere(&merge_rr, fd);
+}
+
+int cmd_rerere(int argc, const char **argv, const char *prefix)
+{
+       struct path_list merge_rr = { NULL, 0, 0, 1 };
+       int i, fd;
+
+       fd = setup_rerere(&merge_rr);
+       if (fd < 0)
+               return 0;
 
        if (argc < 2)
                return do_plain_rerere(&merge_rr, fd);