if (ce_compare_link(ce, xsize_t(st->st_size)))
return DATA_CHANGED;
break;
- case S_IFDIRLNK:
- /* No need to do anything, we did the exact compare in "match_stat_basic" */
- break;
+ case S_IFDIR:
+ if (S_ISDIRLNK(ntohl(ce->ce_mode)))
+ return 0;
default:
return TYPE_CHANGED;
}
changed |= TYPE_CHANGED;
else if (ce_compare_gitlink(ce))
changed |= DATA_CHANGED;
- break;
+ return changed;
default:
die("internal error: ce_mode is %o", ntohl(ce->ce_mode));
}
die("%s: can only add regular files, symbolic links or git-directories", path);
namelen = strlen(path);
+ if (S_ISDIR(st.st_mode)) {
+ while (namelen && path[namelen-1] == '/')
+ namelen--;
+ }
size = cache_entry_size(namelen);
ce = xcalloc(1, size);
memcpy(ce->name, path, namelen);