X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=read-cache.c;h=d2aebdd6bc6dbf7ae40f3a7600d76765f31b9a15;hb=79a9d8ea0d88a3667ad19be8e705405ab5d896f1;hp=ef6fd79e20bf66f5594cf3996d04827f4062bb44;hpb=b0391890d25d9e7ca8f7df2199292df68ead8093;p=git.git diff --git a/read-cache.c b/read-cache.c index ef6fd79e..d2aebdd6 100644 --- a/read-cache.c +++ b/read-cache.c @@ -232,7 +232,7 @@ int remove_cache_entry_at(int pos) return 1; } -int remove_file_from_cache(char *path) +int remove_file_from_cache(const char *path) { int pos = cache_name_pos(path, strlen(path)); if (pos < 0) @@ -464,11 +464,15 @@ int read_cache(void) errno = EBUSY; if (active_cache) - return error("more than one cachefile"); + return active_nr; + errno = ENOENT; fd = open(get_index_file(), O_RDONLY); - if (fd < 0) - return (errno == ENOENT) ? 0 : error("open failed"); + if (fd < 0) { + if (errno == ENOENT) + return 0; + die("index file open failed (%s)", strerror(errno)); + } size = 0; // avoid gcc warning map = MAP_FAILED; @@ -480,7 +484,7 @@ int read_cache(void) } close(fd); if (map == MAP_FAILED) - return error("mmap failed"); + die("index file mmap failed (%s)", strerror(errno)); hdr = map; if (verify_hdr(hdr, size) < 0) @@ -501,7 +505,7 @@ int read_cache(void) unmap: munmap(map, size); errno = EINVAL; - return error("verify header failed"); + die("index file corrupt"); } #define WRITE_BUFFER_SIZE 8192