Commit 769af0fd authored by Junio C Hamano's avatar Junio C Hamano

Merge branch 'jk/cocci'

spatch transformation to replace boolean uses of !hashcmp() to
newly introduced oideq() is added, and applied, to regain
performance lost due to support of multiple hash algorithms.

* jk/cocci:
  show_dirstat: simplify same-content check
  read-cache: use oideq() in ce_compare functions
  convert hashmap comparison functions to oideq()
  convert "hashcmp() != 0" to "!hasheq()"
  convert "oidcmp() != 0" to "!oideq()"
  convert "hashcmp() == 0" to hasheq()
  convert "oidcmp() == 0" to oideq()
  introduce hasheq() and oideq()
  coccinelle: use <...> for function exclusion
parents d88949d8 d9f62dfa
......@@ -596,7 +596,7 @@ static struct commit_list *skip_away(struct commit_list *list, int count)
for (i = 0; cur; cur = cur->next, i++) {
if (i == index) {
if (oidcmp(&cur->item->object.oid, current_bad_oid))
if (!oideq(&cur->item->object.oid, current_bad_oid))
return cur;
if (previous)
return previous;
......@@ -808,7 +808,7 @@ static void check_merge_bases(int rev_nr, struct commit **rev, int no_checkout)
for (; result; result = result->next) {
const struct object_id *mb = &result->item->object.oid;
if (!oidcmp(mb, current_bad_oid)) {
if (oideq(mb, current_bad_oid)) {
handle_bad_merge_base();
} else if (0 <= oid_array_lookup(&good_revs, mb)) {
continue;
......@@ -989,7 +989,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
bisect_rev = &revs.commits->item->object.oid;
if (!oidcmp(bisect_rev, current_bad_oid)) {
if (oideq(bisect_rev, current_bad_oid)) {
exit_if_skipped_commits(tried, current_bad_oid);
printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
term_bad);
......
......@@ -1457,14 +1457,14 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
porigin = find(p, origin);
if (!porigin)
continue;
if (!oidcmp(&porigin->blob_oid, &origin->blob_oid)) {
if (oideq(&porigin->blob_oid, &origin->blob_oid)) {
pass_whole_blame(sb, origin, porigin);
blame_origin_decref(porigin);
goto finish;
}
for (j = same = 0; j < i; j++)
if (sg_origin[j] &&
!oidcmp(&sg_origin[j]->blob_oid, &porigin->blob_oid)) {
oideq(&sg_origin[j]->blob_oid, &porigin->blob_oid)) {
same = 1;
break;
}
......@@ -1832,7 +1832,7 @@ void setup_scoreboard(struct blame_scoreboard *sb,
sb->revs->children.name = "children";
while (c->parents &&
oidcmp(&c->object.oid, &sb->final->object.oid)) {
!oideq(&c->object.oid, &sb->final->object.oid)) {
struct commit_list *l = xcalloc(1, sizeof(*l));
l->item = c;
......@@ -1842,7 +1842,7 @@ void setup_scoreboard(struct blame_scoreboard *sb,
c = c->parents->item;
}
if (oidcmp(&c->object.oid, &sb->final->object.oid))
if (!oideq(&c->object.oid, &sb->final->object.oid))
die(_("--reverse --first-parent together require range along first-parent chain"));
}
......
......@@ -2078,7 +2078,7 @@ static int safe_to_abort(const struct am_state *state)
if (get_oid("HEAD", &head))
oidclr(&head);
if (!oidcmp(&head, &abort_safety))
if (oideq(&head, &abort_safety))
return 1;
warning(_("You seem to have moved HEAD since the last 'am' failure.\n"
......
......@@ -102,7 +102,7 @@ static int update_some(const struct object_id *oid, struct strbuf *base,
if (pos >= 0) {
struct cache_entry *old = active_cache[pos];
if (ce->ce_mode == old->ce_mode &&
!oidcmp(&ce->oid, &old->oid)) {
oideq(&ce->oid, &old->oid)) {
old->ce_flags |= CE_UPDATE;
discard_cache_entry(ce);
return 0;
......
......@@ -62,7 +62,7 @@ static const char *prio_names[] = {
N_("head"), N_("lightweight"), N_("annotated"),
};
static int commit_name_cmp(const void *unused_cmp_data,
static int commit_name_neq(const void *unused_cmp_data,
const void *entry,
const void *entry_or_key,
const void *peeled)
......@@ -70,7 +70,7 @@ static int commit_name_cmp(const void *unused_cmp_data,
const struct commit_name *cn1 = entry;
const struct commit_name *cn2 = entry_or_key;
return oidcmp(&cn1->peeled, peeled ? peeled : &cn2->peeled);
return !oideq(&cn1->peeled, peeled ? peeled : &cn2->peeled);
}
static inline struct commit_name *find_commit_name(const struct object_id *peeled)
......@@ -190,7 +190,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
/* Is it annotated? */
if (!peel_ref(path, &peeled)) {
is_annotated = !!oidcmp(oid, &peeled);
is_annotated = !oideq(oid, &peeled);
} else {
oidcpy(&peeled, oid);
is_annotated = 0;
......@@ -469,7 +469,7 @@ static void process_object(struct object *obj, const char *path, void *data)
{
struct process_commit_data *pcd = data;
if (!oidcmp(&pcd->looking_for, &obj->oid) && !pcd->dst->len) {
if (oideq(&pcd->looking_for, &obj->oid) && !pcd->dst->len) {
reset_revision_walk();
describe_commit(&pcd->current_commit, pcd->dst);
strbuf_addf(pcd->dst, ":%s", path);
......@@ -596,7 +596,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
return cmd_name_rev(args.argc, args.argv, prefix);
}
hashmap_init(&names, commit_name_cmp, NULL, 0);
hashmap_init(&names, commit_name_neq, NULL, 0);
for_each_rawref(get_name, NULL);
if (!hashmap_get_size(&names) && !always)
die(_("No names found, cannot describe anything."));
......
......@@ -41,7 +41,7 @@ static void stuff_change(struct diff_options *opt,
struct diff_filespec *one, *two;
if (!is_null_oid(old_oid) && !is_null_oid(new_oid) &&
!oidcmp(old_oid, new_oid) && (old_mode == new_mode))
oideq(old_oid, new_oid) && (old_mode == new_mode))
return;
if (opt->flags.reverse_diff) {
......
......@@ -116,7 +116,7 @@ static int use_wt_file(const char *workdir, const char *name,
if (is_null_oid(oid)) {
oidcpy(oid, &wt_oid);
use = 1;
} else if (!oidcmp(oid, &wt_oid))
} else if (oideq(oid, &wt_oid))
use = 1;
}
}
......@@ -438,7 +438,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
strbuf_reset(&buf);
strbuf_addf(&buf, "Subproject commit %s",
oid_to_hex(&roid));
if (!oidcmp(&loid, &roid))
if (oideq(&loid, &roid))
strbuf_addstr(&buf, "-dirty");
add_left_or_right(&submodules, dst_path, buf.buf, 1);
continue;
......
......@@ -384,7 +384,7 @@ static void show_filemodify(struct diff_queue_struct *q,
string_list_insert(changed, spec->path);
putchar('\n');
if (!oidcmp(&ospec->oid, &spec->oid) &&
if (oideq(&ospec->oid, &spec->oid) &&
ospec->mode == spec->mode)
break;
}
......
......@@ -239,7 +239,7 @@ static int will_fetch(struct ref **head, const unsigned char *sha1)
{
struct ref *rm = *head;
while (rm) {
if (!hashcmp(rm->old_oid.hash, sha1))
if (hasheq(rm->old_oid.hash, sha1))
return 1;
rm = rm->next;
}
......@@ -508,7 +508,7 @@ static void adjust_refcol_width(const struct ref *ref)
int max, rlen, llen, len;
/* uptodate lines are only shown on high verbosity level */
if (!verbosity && !oidcmp(&ref->peer_ref->old_oid, &ref->old_oid))
if (!verbosity && oideq(&ref->peer_ref->old_oid, &ref->old_oid))
return;
max = term_columns();
......@@ -645,7 +645,7 @@ static int update_local_ref(struct ref *ref,
if (type < 0)
die(_("object %s not found"), oid_to_hex(&ref->new_oid));
if (!oidcmp(&ref->old_oid, &ref->new_oid)) {
if (oideq(&ref->old_oid, &ref->new_oid)) {
if (verbosity > 0)
format_display(display, '=', _("[up to date]"), NULL,
remote, pretty_ref, summary_width);
......
......@@ -79,9 +79,9 @@ static struct merge_parent *find_merge_parent(struct merge_parents *table,
{
int i;
for (i = 0; i < table->nr; i++) {
if (given && oidcmp(&table->item[i].given, given))
if (given && !oideq(&table->item[i].given, given))
continue;
if (commit && oidcmp(&table->item[i].commit, commit))
if (commit && !oideq(&table->item[i].commit, commit))
continue;
return &table->item[i];
}
......@@ -583,7 +583,7 @@ static void find_merge_parents(struct merge_parents *result,
while (parents) {
struct commit *cmit = pop_commit(&parents);
for (i = 0; i < result->nr; i++)
if (!oidcmp(&result->item[i].commit, &cmit->object.oid))
if (oideq(&result->item[i].commit, &cmit->object.oid))
result->item[i].used = 1;
}
......
......@@ -719,9 +719,9 @@ static void find_ref_delta_children(const struct object_id *oid,
*last_index = -1;
return;
}
while (first > 0 && !oidcmp(&ref_deltas[first - 1].oid, oid))
while (first > 0 && oideq(&ref_deltas[first - 1].oid, oid))
--first;
while (last < end && !oidcmp(&ref_deltas[last + 1].oid, oid))
while (last < end && oideq(&ref_deltas[last + 1].oid, oid))
++last;
*first_index = first;
*last_index = last;
......@@ -1166,7 +1166,7 @@ static void parse_pack_objects(unsigned char *hash)
/* Check pack integrity */
flush();
the_hash_algo->final_fn(hash, &input_ctx);
if (hashcmp(fill(the_hash_algo->rawsz), hash))
if (!hasheq(fill(the_hash_algo->rawsz), hash))
die(_("pack is corrupted (SHA1 mismatch)"));
use(the_hash_algo->rawsz);
......@@ -1280,7 +1280,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha
fixup_pack_header_footer(output_fd, pack_hash,
curr_pack, nr_objects,
read_hash, consumed_bytes-the_hash_algo->rawsz);
if (hashcmp(read_hash, tail_hash) != 0)
if (!hasheq(read_hash, tail_hash))
die(_("Unexpected tail checksum for %s "
"(disk corruption?)"), curr_pack);
}
......
......@@ -995,7 +995,7 @@ static char *find_branch_name(struct rev_info *rev)
tip_oid = &rev->cmdline.rev[positive].item->oid;
if (dwim_ref(ref, strlen(ref), &branch_oid, &full_ref) &&
skip_prefix(full_ref, "refs/heads/", &v) &&
!oidcmp(tip_oid, &branch_oid))
oideq(tip_oid, &branch_oid))
branch = xstrdup(v);
free(full_ref);
return branch;
......@@ -1764,7 +1764,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
/* Don't say anything if head and upstream are the same. */
if (rev.pending.nr == 2) {
struct object_array_entry *o = rev.pending.objects;
if (oidcmp(&o[0].item->oid, &o[1].item->oid) == 0)
if (oideq(&o[0].item->oid, &o[1].item->oid))
goto done;
}
get_patch_ids(&rev, &ids);
......@@ -2049,7 +2049,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
/* Don't say anything if head and upstream are the same. */
if (revs.pending.nr == 2) {
struct object_array_entry *o = revs.pending.objects;
if (oidcmp(&o[0].item->oid, &o[1].item->oid) == 0)
if (oideq(&o[0].item->oid, &o[1].item->oid))
return 0;
}
......
......@@ -155,7 +155,7 @@ static int same_entry(struct name_entry *a, struct name_entry *b)
{
return a->oid &&
b->oid &&
!oidcmp(a->oid, b->oid) &&
oideq(a->oid, b->oid) &&
a->mode == b->mode;
}
......
......@@ -1190,7 +1190,7 @@ static int merging_a_throwaway_tag(struct commit *commit)
tag_ref = xstrfmt("refs/tags/%s",
((struct tag *)merge_remote_util(commit)->obj)->tag);
if (!read_ref(tag_ref, &oid) &&
!oidcmp(&oid, &merge_remote_util(commit)->obj->oid))
oideq(&oid, &merge_remote_util(commit)->obj->oid))
is_throwaway_tag = 0;
else
is_throwaway_tag = 1;
......@@ -1449,7 +1449,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done;
} else if (fast_forward != FF_NO && !remoteheads->next &&
!common->next &&
!oidcmp(&common->item->object.oid, &head_commit->object.oid)) {
oideq(&common->item->object.oid, &head_commit->object.oid)) {
/* Again the most common case of merging one remote. */
struct strbuf msg = STRBUF_INIT;
struct commit *commit;
......@@ -1522,7 +1522,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* HEAD^^" would be missed.
*/
common_one = get_merge_bases(head_commit, j->item);
if (oidcmp(&common_one->item->object.oid, &j->item->object.oid)) {
if (!oideq(&common_one->item->object.oid, &j->item->object.oid)) {
up_to_date = 0;
break;
}
......
......@@ -1248,7 +1248,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
*/
for (neigh = 0; neigh < 8; neigh++) {
ent = pbase_tree_cache[my_ix];
if (ent && !oidcmp(&ent->oid, oid)) {
if (ent && oideq(&ent->oid, oid)) {
ent->ref++;
return ent;
}
......@@ -1430,7 +1430,7 @@ static void add_preferred_base(struct object_id *oid)
return;
for (it = pbase_tree; it; it = it->next) {
if (!oidcmp(&it->pcache.oid, &tree_oid)) {
if (oideq(&it->pcache.oid, &tree_oid)) {
free(data);
return;
}
......
......@@ -800,7 +800,7 @@ static int run_rebase(const struct object_id *curr_head,
struct argv_array args = ARGV_ARRAY_INIT;
if (!get_octopus_merge_base(&oct_merge_base, curr_head, merge_head, fork_point))
if (!is_null_oid(fork_point) && !oidcmp(&oct_merge_base, fork_point))
if (!is_null_oid(fork_point) && oideq(&oct_merge_base, fork_point))
fork_point = NULL;
argv_array_push(&args, "rebase");
......@@ -903,7 +903,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
oidclr(&curr_head);
if (!is_null_oid(&orig_head) && !is_null_oid(&curr_head) &&
oidcmp(&orig_head, &curr_head)) {
!oideq(&orig_head, &curr_head)) {
/*
* The fetch involved updating the current branch.
*
......
......@@ -1223,8 +1223,8 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
dst_cmd = (struct command *) item->util;
if (!oidcmp(&cmd->old_oid, &dst_cmd->old_oid) &&
!oidcmp(&cmd->new_oid, &dst_cmd->new_oid))
if (oideq(&cmd->old_oid, &dst_cmd->old_oid) &&
oideq(&cmd->new_oid, &dst_cmd->new_oid))
return;
dst_cmd->skip_update = 1;
......
......@@ -413,7 +413,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
if (is_null_oid(&ref->new_oid)) {
info->status = PUSH_STATUS_DELETE;
} else if (!oidcmp(&ref->old_oid, &ref->new_oid))
} else if (oideq(&ref->old_oid, &ref->new_oid))
info->status = PUSH_STATUS_UPTODATE;
else if (is_null_oid(&ref->old_oid))
info->status = PUSH_STATUS_CREATE;
......
......@@ -343,7 +343,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
}
free(tmpfile);
if (!oidcmp(&old_oid, &new_oid))
if (oideq(&old_oid, &new_oid))
return error(_("new object is the same as the old one: '%s'"), oid_to_hex(&old_oid));
return replace_object_oid(object_ref, &old_oid, "replacement", &new_oid, force);
......@@ -414,7 +414,7 @@ static int check_one_mergetag(struct commit *commit,
if (get_oid(mergetag_data->argv[i], &oid) < 0)
return error(_("not a valid object name: '%s'"),
mergetag_data->argv[i]);
if (!oidcmp(&tag->tagged->oid, &oid))
if (oideq(&tag->tagged->oid, &oid))
return 0; /* found */
}
......@@ -474,7 +474,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
strbuf_release(&buf);
if (!oidcmp(&old_oid, &new_oid)) {
if (oideq(&old_oid, &new_oid)) {
if (gentle) {
warning(_("graft for '%s' unnecessary"), oid_to_hex(&old_oid));
return 0;
......
......@@ -180,7 +180,7 @@ static int check_local_mod(struct object_id *head, int index_only)
if (no_head
|| get_tree_entry(head, name, &oid, &mode)
|| ce->ce_mode != create_ce_mode(mode)
|| oidcmp(&ce->oid, &oid))
|| !oideq(&ce->oid, &oid))
staged_changes = 1;
/*
......
......@@ -412,7 +412,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused.
*/
if (get_oid(refname + ofs, &tmp) || oidcmp(&tmp, oid))
if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
ofs = 5;
return append_ref(refname + ofs, oid, 0);
}
......@@ -427,7 +427,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid,
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused.
*/
if (get_oid(refname + ofs, &tmp) || oidcmp(&tmp, oid))
if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
ofs = 5;
return append_ref(refname + ofs, oid, 0);
}
......@@ -485,7 +485,7 @@ static void snarf_refs(int head, int remotes)
static int rev_is_head(const char *head, const char *name,
unsigned char *head_sha1, unsigned char *sha1)
{
if (!head || (head_sha1 && sha1 && hashcmp(head_sha1, sha1)))
if (!head || (head_sha1 && sha1 && !hasheq(head_sha1, sha1)))
return 0;
skip_prefix(head, "refs/heads/", &head);
if (!skip_prefix(name, "refs/heads/", &name))
......
......@@ -559,7 +559,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
ref_transaction_commit(transaction, &err))
die("%s", err.buf);
ref_transaction_free(transaction);
if (force && !is_null_oid(&prev) && oidcmp(&prev, &object))
if (force && !is_null_oid(&prev) && !oideq(&prev, &object))
printf(_("Updated tag '%s' (was %s)\n"), tag,
find_unique_abbrev(&prev, DEFAULT_ABBREV));
......
......@@ -303,7 +303,7 @@ static void added_object(unsigned nr, enum object_type type,
struct delta_info *info;
while ((info = *p) != NULL) {
if (!oidcmp(&info->base_oid, &obj_list[nr].oid) ||
if (oideq(&info->base_oid, &obj_list[nr].oid) ||
info->base_offset == obj_list[nr].offset) {
*p = info->next;
p = &delta_list;
......@@ -579,7 +579,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
if (fsck_finish(&fsck_options))
die(_("fsck error in pack objects"));
}
if (hashcmp(fill(the_hash_algo->rawsz), oid.hash))
if (!hasheq(fill(the_hash_algo->rawsz), oid.hash))
die("final sha1 did not match");
use(the_hash_algo->rawsz);
......
......@@ -669,7 +669,7 @@ static int unresolve_one(const char *path)
ret = -1;
goto free_return;
}
if (!oidcmp(&ce_2->oid, &ce_3->oid) &&
if (oideq(&ce_2->oid, &ce_3->oid) &&
ce_2->ce_mode == ce_3->ce_mode) {
fprintf(stderr, "%s: identical in both, skipping.\n",
path);
......@@ -754,7 +754,7 @@ static int do_reupdate(int ac, const char **av,
old = read_one_ent(NULL, &head_oid,
ce->name, ce_namelen(ce), 0);
if (old && ce->ce_mode == old->ce_mode &&
!oidcmp(&ce->oid, &old->oid)) {
oideq(&ce->oid, &old->oid)) {
discard_cache_entry(old);
continue; /* unchanged */
}
......
......@@ -72,7 +72,7 @@ static int already_written(struct bulk_checkin_state *state, struct object_id *o
/* Might want to keep the list sorted */
for (i = 0; i < state->nr_written; i++)
if (!oidcmp(&state->written[i]->oid, oid))
if (oideq(&state->written[i]->oid, oid))
return 1;
/* This is a new object we need to keep */
......
......@@ -369,7 +369,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
* commit that is referenced by the tag, and not the tag
* itself.
*/
if (oidcmp(&oid, &e->item->oid)) {
if (!oideq(&oid, &e->item->oid)) {
/*
* Is this the positive end of a range expressed
* in terms of a tag (e.g. v2.0 from the range
......
......@@ -717,7 +717,7 @@ int cache_tree_matches_traversal(struct cache_tree *root,
it = find_cache_tree_from_traversal(root, info);
it = cache_tree_find(it, ent->path);
if (it && it->entry_count > 0 && !oidcmp(ent->oid, &it->oid))
if (it && it->entry_count > 0 && oideq(ent->oid, &it->oid))
return it->entry_count;
return 0;
}
......
......@@ -1041,14 +1041,24 @@ static inline int oidcmp(const struct object_id *oid1, const struct object_id *o
return hashcmp(oid1->hash, oid2->hash);
}
static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
{
return !hashcmp(sha1, sha2);
}
static inline int oideq(const struct object_id *oid1, const struct object_id *oid2)
{
return hasheq(oid1->hash, oid2->hash);
}
static inline int is_null_sha1(const unsigned char *sha1)
{
return !hashcmp(sha1, null_sha1);
return hasheq(sha1, null_sha1);
}
static inline int is_null_oid(const struct object_id *oid)
{
return !hashcmp(oid->hash, null_sha1);
return hasheq(oid->hash, null_sha1);
}
static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
......@@ -1085,22 +1095,22 @@ static inline void oidread(struct object_id *oid, const unsigned char *hash)
static inline int is_empty_blob_sha1(const unsigned char *sha1)
{
return !hashcmp(sha1, the_hash_algo->empty_blob->hash);
return hasheq(sha1, the_hash_algo->empty_blob->hash);
}
static inline int is_empty_blob_oid(const struct object_id *oid)
{
return !oidcmp(oid, the_hash_algo->empty_blob);
return oideq(oid, the_hash_algo->empty_blob);
}
static inline int is_empty_tree_sha1(const unsigned char *sha1)
{
return !hashcmp(sha1, the_hash_algo->empty_tree->hash);
return hasheq(sha1, the_hash_algo->empty_tree->hash);
}
static inline int is_empty_tree_oid(const struct object_id *oid)
{
return !oidcmp(oid, the_hash_algo->empty_tree);
return oideq(oid, the_hash_algo->empty_tree);
}
const char *empty_tree_oid_hex(void);
......
......@@ -1138,8 +1138,8 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
for (i = 0; i < num_parent; i++) {
int j;
for (j = 0; j < i; j++) {
if (!oidcmp(&elem->parent[i].oid,
&elem->parent[j].oid)) {
if (oideq(&elem->parent[i].oid,
&elem->parent[j].oid)) {
reuse_combine_diff(sline, cnt, i, j);
break;
}
......
......@@ -783,7 +783,7 @@ void write_commit_graph(const char *obj_dir,
count_distinct = 1;
for (i = 1; i < oids.nr; i++) {
if (oidcmp(&oids.list[i-1], &oids.list[i]))
if (!oideq(&oids.list[i - 1], &oids.list[i]))
count_distinct++;
}
......@@ -797,7 +797,7 @@ void write_commit_graph(const char *obj_dir,
num_extra_edges = 0;
for (i = 0; i < oids.nr; i++) {
int num_parents = 0;
if (i > 0 && !oidcmp(&oids.list[i-1], &oids.list[i]))
if (i > 0 && oideq(&oids.list[i - 1], &oids.list[i]))
continue;
commits.list[commits.nr] = lookup_commit(the_repository, &oids.list[i]);
......@@ -918,7 +918,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
f = hashfd(devnull, NULL);
hashwrite(f, g->data, g->data_len - g->hash_len);
finalize_hashfile(f, checksum.hash, CSUM_CLOSE);
if (hashcmp(checksum.hash, g->data + g->data_len - g->hash_len)) {
if (!hasheq(checksum.hash, g->data + g->data_len - g->hash_len)) {
graph_report(_("the commit-graph file has incorrect checksum and is likely corrupt"));
verify_commit_graph_error = VERIFY_COMMIT_GRAPH_ERROR_HASH;
}
......@@ -978,7 +978,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
continue;
}
if (oidcmp(&get_commit_tree_in_graph_one(g, graph_commit)->object.oid,
if (!oideq(&get_commit_tree_in_graph_one(g, graph_commit)->object.oid,
get_commit_tree_oid(odb_commit)))
graph_report("root tree OID for commit %s in commit-graph is %s != %s",
oid_to_hex(&cur_oid),
......@@ -995,7 +995,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
break;
}
if (oidcmp(&graph_parents->item->object.oid, &odb_parents->item->object.oid))
if (!oideq(&graph_parents->item->object.oid, &odb_parents->item->object.oid))
graph_report("commit-graph parent for %s is %s != %s",
oid_to_hex(&cur_oid),
oid_to_hex(&graph_parents->item->object.oid),
......
......@@ -46,7 +46,7 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref
struct commit *c = lookup_commit_reference(the_repository, oid);
if (!c)
die(_("could not parse %s"), ref_name);
if (oidcmp(oid, &c->object.oid)) {
if (!oideq(oid, &c->object.oid)) {
warning(_("%s %s is not a commit!"),
ref_name, oid_to_hex(oid));
}
......
......@@ -224,7 +224,7 @@ static int process_dummy_ref(const char *line)
return 0;
name++;
return !oidcmp(&null_oid, &oid) && !strcmp(name, "capabilities^{}");
return oideq(&null_oid, &oid) && !strcmp(name, "capabilities^{}");
}
static void check_no_capabilities(const char *line, int len)
......
......@@ -15,10 +15,10 @@ expression c;
identifier f !~ "^(get_commit_tree|get_commit_tree_in_graph_one|load_tree_for_commit)$";
expression c;
@@
f(...) {...
f(...) {<...
- c->maybe_tree
+ get_commit_tree(c)
...}
...>}
@@
expression c;
......
......@@ -20,10 +20,10 @@ expression E1;
identifier f != oid_to_hex;
expression E1;
@@
f(...) {...
f(...) {<...
- sha1_to_hex(E1->hash)
+ oid_to_hex(E1)
...}
...>}
@@
expression E1, E2;
......@@ -35,10 +35,10 @@ expression E1, E2;
identifier f != oid_to_hex_r;
expression E1, E2;
@@
f(...) {...
f(...) {<...
- sha1_to_hex_r(E1, E2->hash)
+ oid_to_hex_r(E1, E2)
...}
...>}
@@
expression E1;
......@@ -50,10 +50,10 @@ expression E1;
identifier f != oidclr;
expression E1;
@@
f(...) {...
f(...) {<...
- hashclr(E1->hash)
+ oidclr(E1)
...}
...>}
@@
expression E1, E2;
......@@ -65,10 +65,10 @@ expression E1, E2;
identifier f != oidcmp;