cache.h: document remove_index_entry_at
[gitweb.git] / read-cache.c
index 38d67faf708d7b88f208f10dad23f893dd16f587..585ff02dc3307daf1959867183b1beed0917fb0b 100644 (file)
@@ -156,7 +156,14 @@ void fill_stat_cache_info(struct cache_entry *ce, struct stat *st)
 static int ce_compare_data(const struct cache_entry *ce, struct stat *st)
 {
        int match = -1;
-       int fd = open(ce->name, O_RDONLY);
+       static int cloexec = O_CLOEXEC;
+       int fd = open(ce->name, O_RDONLY | cloexec);
+
+       if ((cloexec & O_CLOEXEC) && fd < 0 && errno == EINVAL) {
+               /* Try again w/o O_CLOEXEC: the kernel might not support it */
+               cloexec &= ~O_CLOEXEC;
+               fd = open(ce->name, O_RDONLY | cloexec);
+       }
 
        if (fd >= 0) {
                unsigned char sha1[20];
@@ -503,7 +510,6 @@ int index_name_pos(const struct index_state *istate, const char *name, int namel
        return index_name_stage_pos(istate, name, namelen, 0);
 }
 
-/* Remove entry, return true if there are more entries to go.. */
 int remove_index_entry_at(struct index_state *istate, int pos)
 {
        struct cache_entry *ce = istate->cache[pos];