extern int discard_index(struct index_state *);
extern int unmerged_index(const struct index_state *);
extern int verify_path(const char *path);
-extern int index_name_exists(struct index_state *istate, const char *name, int namelen);
+extern struct cache_entry *index_name_exists(struct index_state *istate, const char *name, int namelen);
extern int index_name_pos(const struct index_state *, const char *name, int namelen);
#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */
#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */
hash_index_entry(istate, ce);
}
-int index_name_exists(struct index_state *istate, const char *name, int namelen)
+struct cache_entry *index_name_exists(struct index_state *istate, const char *name, int namelen)
{
unsigned int hash = hash_name(name, namelen);
struct cache_entry *ce;
while (ce) {
if (!(ce->ce_flags & CE_UNHASHED)) {
if (!cache_name_compare(name, namelen, ce->name, ce->ce_flags))
- return 1;
+ return ce;
}
ce = ce->next;
}
- return 0;
+ return NULL;
}
if (!lstat(ce->name, &st)) {
int cnt;
int dtype = ce_to_dtype(ce);
+ struct cache_entry *result;
if (o->dir && excluded(o->dir, ce->name, &dtype))
/*
* delete this path, which is in a subdirectory that
* is being replaced with a blob.
*/
- cnt = index_name_pos(&o->result, ce->name, strlen(ce->name));
- if (0 <= cnt) {
- struct cache_entry *ce = o->result.cache[cnt];
- if (ce->ce_flags & CE_REMOVE)
+ result = index_name_exists(&o->result, ce->name, ce_namelen(ce));
+ if (result) {
+ if (result->ce_flags & CE_REMOVE)
return 0;
}