[PATCH] Fix +x-related show-diff false positives
[git.git] / read-cache.c
index 21f6e8e..042b0c2 100644 (file)
@@ -304,7 +304,7 @@ int cache_match_stat(struct cache_entry *ce, struct stat *st)
            ce->ce_gid != htonl(st->st_gid))
                changed |= OWNER_CHANGED;
        /* We consider only the owner x bit to be relevant for "mode changes" */
-       if (0100 & (ntohs(ce->ce_mode) ^ st->st_mode))
+       if (0100 & (ntohl(ce->ce_mode) ^ st->st_mode))
                changed |= MODE_CHANGED;
        if (ce->ce_dev != htonl(st->st_dev) ||
            ce->ce_ino != htonl(st->st_ino))
@@ -369,7 +369,9 @@ static int remove_entry_at(int pos)
 int remove_file_from_cache(char *path)
 {
        int pos = cache_name_pos(path, strlen(path));
-       if (pos >= 0)
+       if (pos < 0)
+               pos = -pos-1;
+       while (pos < active_nr && !strcmp(active_cache[pos]->name, path))
                remove_entry_at(pos);
        return 0;
 }