Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/read-cache.c b/read-cache.c
index b707edd044..01859b7703 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -215,7 +215,7 @@ static int ce_compare_data(struct index_state *istate,
if (fd >= 0) {
struct object_id oid;
if (!index_fd(istate, &oid, fd, st, OBJ_BLOB, ce->name, 0))
- match = oidcmp(&oid, &ce->oid);
+ match = !oideq(&oid, &ce->oid);
/* index_fd() closed the file descriptor already */
}
return match;
@@ -256,7 +256,7 @@ static int ce_compare_gitlink(const struct cache_entry *ce)
*/
if (resolve_gitlink_ref(ce->name, "HEAD", &oid) < 0)
return 0;
- return oidcmp(&oid, &ce->oid);
+ return !oideq(&oid, &ce->oid);
}
static int ce_modified_check_fs(struct index_state *istate,
@@ -771,7 +771,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
/* It was suspected to be racily clean, but it turns out to be Ok */
was_same = (alias &&
!ce_stage(alias) &&
- !oidcmp(&alias->oid, &ce->oid) &&
+ oideq(&alias->oid, &ce->oid) &&
ce->ce_mode == alias->ce_mode);
if (pretend)
@@ -1480,8 +1480,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,
const char *typechange_fmt;
const char *added_fmt;
const char *unmerged_fmt;
- uint64_t start = getnanotime();
+ trace_performance_enter();
modified_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n");
deleted_fmt = (in_porcelain ? "D\t%s\n" : "%s: needs update\n");
typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
@@ -1551,7 +1551,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
replace_index_entry(istate, i, new_entry);
}
- trace_performance_since(start, "refresh index");
+ trace_performance_leave("refresh index");
return has_errors;
}
@@ -1672,7 +1672,7 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
the_hash_algo->init_fn(&c);
the_hash_algo->update_fn(&c, hdr, size - the_hash_algo->rawsz);
the_hash_algo->final_fn(hash, &c);
- if (hashcmp(hash, (unsigned char *)hdr + size - the_hash_algo->rawsz))
+ if (!hasheq(hash, (unsigned char *)hdr + size - the_hash_algo->rawsz))
return error("bad index file sha1 signature");
return 0;
}
@@ -2006,7 +2006,6 @@ static void freshen_shared_index(const char *shared_index, int warn)
int read_index_from(struct index_state *istate, const char *path,
const char *gitdir)
{
- uint64_t start = getnanotime();
struct split_index *split_index;
int ret;
char *base_oid_hex;
@@ -2016,8 +2015,9 @@ int read_index_from(struct index_state *istate, const char *path,
if (istate->initialized)
return istate->cache_nr;
+ trace_performance_enter();
ret = do_read_index(istate, path, 0);
- trace_performance_since(start, "read cache %s", path);
+ trace_performance_leave("read cache %s", path);
split_index = istate->split_index;
if (!split_index || is_null_oid(&split_index->base_oid)) {
@@ -2025,6 +2025,7 @@ int read_index_from(struct index_state *istate, const char *path,
return ret;
}
+ trace_performance_enter();
if (split_index->base)
discard_index(split_index->base);
else
@@ -2033,7 +2034,7 @@ int read_index_from(struct index_state *istate, const char *path,
base_oid_hex = oid_to_hex(&split_index->base_oid);
base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
ret = do_read_index(split_index->base, base_path, 1);
- if (oidcmp(&split_index->base_oid, &split_index->base->oid))
+ if (!oideq(&split_index->base_oid, &split_index->base->oid))
die("broken index, expect %s in %s, got %s",
base_oid_hex, base_path,
oid_to_hex(&split_index->base->oid));
@@ -2041,8 +2042,8 @@ int read_index_from(struct index_state *istate, const char *path,
freshen_shared_index(base_path, 0);
merge_base_index(istate);
post_read_index_from(istate);
- trace_performance_since(start, "read cache %s", base_path);
free(base_path);
+ trace_performance_leave("read cache %s", base_path);
return ret;
}
@@ -2400,7 +2401,7 @@ static int verify_index_from(const struct index_state *istate, const char *path)
if (n != the_hash_algo->rawsz)
goto out;
- if (hashcmp(istate->oid.hash, hash))
+ if (!hasheq(istate->oid.hash, hash))
goto out;
close(fd);
@@ -2748,6 +2749,9 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
int new_shared_index, ret;
struct split_index *si = istate->split_index;
+ if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0))
+ cache_tree_verify(istate);
+
if ((flags & SKIP_IF_UNCHANGED) && !istate->cache_changed) {
if (flags & COMMIT_LOCK)
rollback_lock_file(lock);
@@ -2944,6 +2948,8 @@ void move_index_extensions(struct index_state *dst, struct index_state *src)
{
dst->untracked = src->untracked;
src->untracked = NULL;
+ dst->cache_tree = src->cache_tree;
+ src->cache_tree = NULL;
}
struct cache_entry *dup_cache_entry(const struct cache_entry *ce,