travis-ci: record and skip successfully built trees
[gitweb.git] / rerere.c
index aaadec17d867d521fc0eaab7fcdd2e871bdf1267..70634d456cc0b70cdbac1579b82016761252c7d9 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "config.h"
 #include "lockfile.h"
 #include "string-list.h"
 #include "rerere.h"
@@ -39,9 +40,8 @@ static void free_rerere_dirs(void)
                free(rerere_dir[i]->status);
                free(rerere_dir[i]);
        }
-       free(rerere_dir);
+       FREE_AND_NULL(rerere_dir);
        rerere_dir_nr = rerere_dir_alloc = 0;
-       rerere_dir = NULL;
 }
 
 static void free_rerere_id(struct string_list_item *item)
@@ -200,7 +200,7 @@ static struct rerere_id *new_rerere_id(unsigned char *sha1)
 static void read_rr(struct string_list *rr)
 {
        struct strbuf buf = STRBUF_INIT;
-       FILE *in = fopen(git_path_merge_rr(), "r");
+       FILE *in = fopen_or_warn(git_path_merge_rr(), "r");
 
        if (!in)
                return;
@@ -484,13 +484,14 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
        io.input = fopen(path, "r");
        io.io.wrerror = 0;
        if (!io.input)
-               return error("Could not open %s", path);
+               return error_errno("Could not open %s", path);
 
        if (output) {
                io.io.output = fopen(output, "w");
                if (!io.io.output) {
+                       error_errno("Could not write %s", output);
                        fclose(io.input);
-                       return error("Could not write %s", output);
+                       return -1;
                }
        }
 
@@ -708,7 +709,7 @@ static void update_paths(struct string_list *update)
 {
        int i;
 
-       hold_locked_index(&index_lock, 1);
+       hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
 
        for (i = 0; i < update->nr; i++) {
                struct string_list_item *item = &update->items[i];
@@ -980,7 +981,8 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
                        break;
                i = ce_stage(ce) - 1;
                if (!mmfile[i].ptr) {
-                       mmfile[i].ptr = read_sha1_file(ce->sha1, &type, &size);
+                       mmfile[i].ptr = read_sha1_file(ce->oid.hash, &type,
+                                                      &size);
                        mmfile[i].size = size;
                }
        }