summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 96872bc)
raw | patch | inline | side by side (parent: 96872bc)
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | |
Fri, 21 Mar 2008 22:53:00 +0000 (15:53 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 9 Apr 2008 08:22:25 +0000 (01:22 -0700) |
This allows verify_absent() in unpack_trees() to use the hash chains
rather than looking it up using the binary search.
Perhaps more importantly, it's also going to be useful for the next phase,
where we actually start looking at the cache entry when we do
case-insensitive lookups and checking the result.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
rather than looking it up using the binary search.
Perhaps more importantly, it's also going to be useful for the next phase,
where we actually start looking at the cache entry when we do
case-insensitive lookups and checking the result.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h | patch | blob | history | |
name-hash.c | patch | blob | history | |
unpack-trees.c | patch | blob | history |
index 2afc788f747e7865100e62cc02e9b99e69844db4..76d95d2c813c4072ff1a8a52976a0893fc22365b 100644 (file)
--- a/cache.h
+++ b/cache.h
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 */
diff --git a/name-hash.c b/name-hash.c
index e56eb16c2836b3e4227cffed68703e9d42b51b9e..2678148937cc3614fbb003ae3826830ed2097b52 100644 (file)
--- a/name-hash.c
+++ b/name-hash.c
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;
}
diff --git a/unpack-trees.c b/unpack-trees.c
index a59f47557a2b3760c27b93fa678697c35211f952..ca4c845beb3d9cd61c60ce9592e264bc9d53f592 100644 (file)
--- a/unpack-trees.c
+++ b/unpack-trees.c
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;
}