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) ...@@ -596,7 +596,7 @@ static struct commit_list *skip_away(struct commit_list *list, int count)
for (i = 0; cur; cur = cur->next, i++) { for (i = 0; cur; cur = cur->next, i++) {
if (i == index) { if (i == index) {
if (oidcmp(&cur->item->object.oid, current_bad_oid)) if (!oideq(&cur->item->object.oid, current_bad_oid))
return cur; return cur;
if (previous) if (previous)
return previous; return previous;
...@@ -808,7 +808,7 @@ static void check_merge_bases(int rev_nr, struct commit **rev, int no_checkout) ...@@ -808,7 +808,7 @@ static void check_merge_bases(int rev_nr, struct commit **rev, int no_checkout)
for (; result; result = result->next) { for (; result; result = result->next) {
const struct object_id *mb = &result->item->object.oid; 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(); handle_bad_merge_base();
} else if (0 <= oid_array_lookup(&good_revs, mb)) { } else if (0 <= oid_array_lookup(&good_revs, mb)) {
continue; continue;
...@@ -989,7 +989,7 @@ int bisect_next_all(const char *prefix, int no_checkout) ...@@ -989,7 +989,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
bisect_rev = &revs.commits->item->object.oid; 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); exit_if_skipped_commits(tried, current_bad_oid);
printf("%s is the first %s commit\n", oid_to_hex(bisect_rev), printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
term_bad); term_bad);
......
...@@ -1457,14 +1457,14 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin, ...@@ -1457,14 +1457,14 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
porigin = find(p, origin); porigin = find(p, origin);
if (!porigin) if (!porigin)
continue; continue;
if (!oidcmp(&porigin->blob_oid, &origin->blob_oid)) { if (oideq(&porigin->blob_oid, &origin->blob_oid)) {
pass_whole_blame(sb, origin, porigin); pass_whole_blame(sb, origin, porigin);
blame_origin_decref(porigin); blame_origin_decref(porigin);
goto finish; goto finish;
} }
for (j = same = 0; j < i; j++) for (j = same = 0; j < i; j++)
if (sg_origin[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; same = 1;
break; break;
} }
...@@ -1832,7 +1832,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, ...@@ -1832,7 +1832,7 @@ void setup_scoreboard(struct blame_scoreboard *sb,
sb->revs->children.name = "children"; sb->revs->children.name = "children";
while (c->parents && 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)); struct commit_list *l = xcalloc(1, sizeof(*l));
l->item = c; l->item = c;
...@@ -1842,7 +1842,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, ...@@ -1842,7 +1842,7 @@ void setup_scoreboard(struct blame_scoreboard *sb,
c = c->parents->item; 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")); 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) ...@@ -2078,7 +2078,7 @@ static int safe_to_abort(const struct am_state *state)
if (get_oid("HEAD", &head)) if (get_oid("HEAD", &head))
oidclr(&head); oidclr(&head);
if (!oidcmp(&head, &abort_safety)) if (oideq(&head, &abort_safety))
return 1; return 1;
warning(_("You seem to have moved HEAD since the last 'am' failure.\n" 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, ...@@ -102,7 +102,7 @@ static int update_some(const struct object_id *oid, struct strbuf *base,
if (pos >= 0) { if (pos >= 0) {
struct cache_entry *old = active_cache[pos]; struct cache_entry *old = active_cache[pos];
if (ce->ce_mode == old->ce_mode && if (ce->ce_mode == old->ce_mode &&
!oidcmp(&ce->oid, &old->oid)) { oideq(&ce->oid, &old->oid)) {
old->ce_flags |= CE_UPDATE; old->ce_flags |= CE_UPDATE;
discard_cache_entry(ce); discard_cache_entry(ce);
return 0; return 0;
......
...@@ -62,7 +62,7 @@ static const char *prio_names[] = { ...@@ -62,7 +62,7 @@ static const char *prio_names[] = {
N_("head"), N_("lightweight"), N_("annotated"), 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,
const void *entry_or_key, const void *entry_or_key,
const void *peeled) const void *peeled)
...@@ -70,7 +70,7 @@ static int commit_name_cmp(const void *unused_cmp_data, ...@@ -70,7 +70,7 @@ static int commit_name_cmp(const void *unused_cmp_data,
const struct commit_name *cn1 = entry; const struct commit_name *cn1 = entry;
const struct commit_name *cn2 = entry_or_key; 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) 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 ...@@ -190,7 +190,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
/* Is it annotated? */ /* Is it annotated? */
if (!peel_ref(path, &peeled)) { if (!peel_ref(path, &peeled)) {
is_annotated = !!oidcmp(oid, &peeled); is_annotated = !oideq(oid, &peeled);
} else { } else {
oidcpy(&peeled, oid); oidcpy(&peeled, oid);
is_annotated = 0; is_annotated = 0;
...@@ -469,7 +469,7 @@ static void process_object(struct object *obj, const char *path, void *data) ...@@ -469,7 +469,7 @@ static void process_object(struct object *obj, const char *path, void *data)
{ {
struct process_commit_data *pcd = 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(); reset_revision_walk();
describe_commit(&pcd->current_commit, pcd->dst); describe_commit(&pcd->current_commit, pcd->dst);
strbuf_addf(pcd->dst, ":%s", path); strbuf_addf(pcd->dst, ":%s", path);
...@@ -596,7 +596,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix) ...@@ -596,7 +596,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
return cmd_name_rev(args.argc, args.argv, 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); for_each_rawref(get_name, NULL);
if (!hashmap_get_size(&names) && !always) if (!hashmap_get_size(&names) && !always)
die(_("No names found, cannot describe anything.")); die(_("No names found, cannot describe anything."));
......
...@@ -41,7 +41,7 @@ static void stuff_change(struct diff_options *opt, ...@@ -41,7 +41,7 @@ static void stuff_change(struct diff_options *opt,
struct diff_filespec *one, *two; struct diff_filespec *one, *two;
if (!is_null_oid(old_oid) && !is_null_oid(new_oid) && 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; return;
if (opt->flags.reverse_diff) { if (opt->flags.reverse_diff) {
......
...@@ -116,7 +116,7 @@ static int use_wt_file(const char *workdir, const char *name, ...@@ -116,7 +116,7 @@ static int use_wt_file(const char *workdir, const char *name,
if (is_null_oid(oid)) { if (is_null_oid(oid)) {
oidcpy(oid, &wt_oid); oidcpy(oid, &wt_oid);
use = 1; use = 1;
} else if (!oidcmp(oid, &wt_oid)) } else if (oideq(oid, &wt_oid))
use = 1; use = 1;
} }
} }
...@@ -438,7 +438,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix, ...@@ -438,7 +438,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
strbuf_reset(&buf); strbuf_reset(&buf);
strbuf_addf(&buf, "Subproject commit %s", strbuf_addf(&buf, "Subproject commit %s",
oid_to_hex(&roid)); oid_to_hex(&roid));
if (!oidcmp(&loid, &roid)) if (oideq(&loid, &roid))
strbuf_addstr(&buf, "-dirty"); strbuf_addstr(&buf, "-dirty");
add_left_or_right(&submodules, dst_path, buf.buf, 1); add_left_or_right(&submodules, dst_path, buf.buf, 1);
continue; continue;
......
...@@ -384,7 +384,7 @@ static void show_filemodify(struct diff_queue_struct *q, ...@@ -384,7 +384,7 @@ static void show_filemodify(struct diff_queue_struct *q,
string_list_insert(changed, spec->path); string_list_insert(changed, spec->path);
putchar('\n'); putchar('\n');
if (!oidcmp(&ospec->oid, &spec->oid) && if (oideq(&ospec->oid, &spec->oid) &&
ospec->mode == spec->mode) ospec->mode == spec->mode)
break; break;
} }
......
...@@ -239,7 +239,7 @@ static int will_fetch(struct ref **head, const unsigned char *sha1) ...@@ -239,7 +239,7 @@ static int will_fetch(struct ref **head, const unsigned char *sha1)
{ {
struct ref *rm = *head; struct ref *rm = *head;
while (rm) { while (rm) {
if (!hashcmp(rm->old_oid.hash, sha1)) if (hasheq(rm->old_oid.hash, sha1))
return 1; return 1;
rm = rm->next; rm = rm->next;
} }
...@@ -508,7 +508,7 @@ static void adjust_refcol_width(const struct ref *ref) ...@@ -508,7 +508,7 @@ static void adjust_refcol_width(const struct ref *ref)
int max, rlen, llen, len; int max, rlen, llen, len;
/* uptodate lines are only shown on high verbosity level */ /* 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; return;
max = term_columns(); max = term_columns();
...@@ -645,7 +645,7 @@ static int update_local_ref(struct ref *ref, ...@@ -645,7 +645,7 @@ static int update_local_ref(struct ref *ref,
if (type < 0) if (type < 0)
die(_("object %s not found"), oid_to_hex(&ref->new_oid)); 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) if (verbosity > 0)
format_display(display, '=', _("[up to date]"), NULL, format_display(display, '=', _("[up to date]"), NULL,
remote, pretty_ref, summary_width); remote, pretty_ref, summary_width);
......
...@@ -79,9 +79,9 @@ static struct merge_parent *find_merge_parent(struct merge_parents *table, ...@@ -79,9 +79,9 @@ static struct merge_parent *find_merge_parent(struct merge_parents *table,
{ {
int i; int i;
for (i = 0; i < table->nr; 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; continue;
if (commit && oidcmp(&table->item[i].commit, commit)) if (commit && !oideq(&table->item[i].commit, commit))
continue; continue;
return &table->item[i]; return &table->item[i];
} }
...@@ -583,7 +583,7 @@ static void find_merge_parents(struct merge_parents *result, ...@@ -583,7 +583,7 @@ static void find_merge_parents(struct merge_parents *result,
while (parents) { while (parents) {
struct commit *cmit = pop_commit(&parents); struct commit *cmit = pop_commit(&parents);
for (i = 0; i < result->nr; i++) 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; result->item[i].used = 1;
} }
......
...@@ -719,9 +719,9 @@ static void find_ref_delta_children(const struct object_id *oid, ...@@ -719,9 +719,9 @@ static void find_ref_delta_children(const struct object_id *oid,
*last_index = -1; *last_index = -1;
return; return;
} }
while (first > 0 && !oidcmp(&ref_deltas[first - 1].oid, oid)) while (first > 0 && oideq(&ref_deltas[first - 1].oid, oid))
--first; --first;
while (last < end && !oidcmp(&ref_deltas[last + 1].oid, oid)) while (last < end && oideq(&ref_deltas[last + 1].oid, oid))
++last; ++last;
*first_index = first; *first_index = first;
*last_index = last; *last_index = last;
...@@ -1166,7 +1166,7 @@ static void parse_pack_objects(unsigned char *hash) ...@@ -1166,7 +1166,7 @@ static void parse_pack_objects(unsigned char *hash)
/* Check pack integrity */ /* Check pack integrity */
flush(); flush();
the_hash_algo->final_fn(hash, &input_ctx); 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)")); die(_("pack is corrupted (SHA1 mismatch)"));
use(the_hash_algo->rawsz); use(the_hash_algo->rawsz);
...@@ -1280,7 +1280,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha ...@@ -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, fixup_pack_header_footer(output_fd, pack_hash,
curr_pack, nr_objects, curr_pack, nr_objects,
read_hash, consumed_bytes-the_hash_algo->rawsz); 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 " die(_("Unexpected tail checksum for %s "
"(disk corruption?)"), curr_pack); "(disk corruption?)"), curr_pack);
} }
......
...@@ -995,7 +995,7 @@ static char *find_branch_name(struct rev_info *rev) ...@@ -995,7 +995,7 @@ static char *find_branch_name(struct rev_info *rev)
tip_oid = &rev->cmdline.rev[positive].item->oid; tip_oid = &rev->cmdline.rev[positive].item->oid;
if (dwim_ref(ref, strlen(ref), &branch_oid, &full_ref) && if (dwim_ref(ref, strlen(ref), &branch_oid, &full_ref) &&
skip_prefix(full_ref, "refs/heads/", &v) && skip_prefix(full_ref, "refs/heads/", &v) &&
!oidcmp(tip_oid, &branch_oid)) oideq(tip_oid, &branch_oid))
branch = xstrdup(v); branch = xstrdup(v);
free(full_ref); free(full_ref);
return branch; return branch;
...@@ -1764,7 +1764,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) ...@@ -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. */ /* Don't say anything if head and upstream are the same. */
if (rev.pending.nr == 2) { if (rev.pending.nr == 2) {
struct object_array_entry *o = rev.pending.objects; 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; goto done;
} }
get_patch_ids(&rev, &ids); get_patch_ids(&rev, &ids);
...@@ -2049,7 +2049,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) ...@@ -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. */ /* Don't say anything if head and upstream are the same. */
if (revs.pending.nr == 2) { if (revs.pending.nr == 2) {
struct object_array_entry *o = revs.pending.objects; 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; return 0;
} }
......
...@@ -155,7 +155,7 @@ static int same_entry(struct name_entry *a, struct name_entry *b) ...@@ -155,7 +155,7 @@ static int same_entry(struct name_entry *a, struct name_entry *b)
{ {
return a->oid && return a->oid &&
b->oid && b->oid &&
!oidcmp(a->oid, b->oid) && oideq(a->oid, b->oid) &&
a->mode == b->mode; a->mode == b->mode;
} }
......
...@@ -1190,7 +1190,7 @@ static int merging_a_throwaway_tag(struct commit *commit) ...@@ -1190,7 +1190,7 @@ static int merging_a_throwaway_tag(struct commit *commit)
tag_ref = xstrfmt("refs/tags/%s", tag_ref = xstrfmt("refs/tags/%s",
((struct tag *)merge_remote_util(commit)->obj)->tag); ((struct tag *)merge_remote_util(commit)->obj)->tag);
if (!read_ref(tag_ref, &oid) && 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; is_throwaway_tag = 0;
else else
is_throwaway_tag = 1; is_throwaway_tag = 1;
...@@ -1449,7 +1449,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) ...@@ -1449,7 +1449,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done; goto done;
} else if (fast_forward != FF_NO && !remoteheads->next && } else if (fast_forward != FF_NO && !remoteheads->next &&
!common->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. */ /* Again the most common case of merging one remote. */
struct strbuf msg = STRBUF_INIT; struct strbuf msg = STRBUF_INIT;
struct commit *commit; struct commit *commit;
...@@ -1522,7 +1522,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) ...@@ -1522,7 +1522,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* HEAD^^" would be missed. * HEAD^^" would be missed.
*/ */
common_one = get_merge_bases(head_commit, j->item); 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; up_to_date = 0;
break; break;
} }
......
...@@ -1248,7 +1248,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid) ...@@ -1248,7 +1248,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
*/ */
for (neigh = 0; neigh < 8; neigh++) { for (neigh = 0; neigh < 8; neigh++) {
ent = pbase_tree_cache[my_ix]; ent = pbase_tree_cache[my_ix];
if (ent && !oidcmp(&ent->oid, oid)) { if (ent && oideq(&ent->oid, oid)) {
ent->ref++; ent->ref++;
return ent; return ent;
} }
...@@ -1430,7 +1430,7 @@ static void add_preferred_base(struct object_id *oid) ...@@ -1430,7 +1430,7 @@ static void add_preferred_base(struct object_id *oid)
return; return;
for (it = pbase_tree; it; it = it->next) { for (it = pbase_tree; it; it = it->next) {
if (!oidcmp(&it->pcache.oid, &tree_oid)) { if (oideq(&it->pcache.oid, &tree_oid)) {
free(data); free(data);
return; return;
} }
......
...@@ -800,7 +800,7 @@ static int run_rebase(const struct object_id *curr_head, ...@@ -800,7 +800,7 @@ static int run_rebase(const struct object_id *curr_head,
struct argv_array args = ARGV_ARRAY_INIT; struct argv_array args = ARGV_ARRAY_INIT;
if (!get_octopus_merge_base(&oct_merge_base, curr_head, merge_head, fork_point)) 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; fork_point = NULL;
argv_array_push(&args, "rebase"); argv_array_push(&args, "rebase");
...@@ -903,7 +903,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) ...@@ -903,7 +903,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
oidclr(&curr_head); oidclr(&curr_head);
if (!is_null_oid(&orig_head) && !is_null_oid(&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. * The fetch involved updating the current branch.
* *
......
...@@ -1223,8 +1223,8 @@ static void check_aliased_update(struct command *cmd, struct string_list *list) ...@@ -1223,8 +1223,8 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
dst_cmd = (struct command *) item->util; dst_cmd = (struct command *) item->util;
if (!oidcmp(&cmd->old_oid, &dst_cmd->old_oid) && if (oideq(&cmd->old_oid, &dst_cmd->old_oid) &&
!oidcmp(&cmd->new_oid, &dst_cmd->new_oid)) oideq(&cmd->new_oid, &dst_cmd->new_oid))
return; return;
dst_cmd->skip_update = 1; dst_cmd->skip_update = 1;
......
...@@ -413,7 +413,7 @@ static int get_push_ref_states(const struct ref *remote_refs, ...@@ -413,7 +413,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
if (is_null_oid(&ref->new_oid)) { if (is_null_oid(&ref->new_oid)) {
info->status = PUSH_STATUS_DELETE; 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; info->status = PUSH_STATUS_UPTODATE;
else if (is_null_oid(&ref->old_oid)) else if (is_null_oid(&ref->old_oid))
info->status = PUSH_STATUS_CREATE; info->status = PUSH_STATUS_CREATE;
......
...@@ -343,7 +343,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw) ...@@ -343,7 +343,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
} }
free(tmpfile); 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 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); return replace_object_oid(object_ref, &old_oid, "replacement", &new_oid, force);
...@@ -414,7 +414,7 @@ static int check_one_mergetag(struct commit *commit, ...@@ -414,7 +414,7 @@ static int check_one_mergetag(struct commit *commit,
if (get_oid(mergetag_data->argv[i], &oid) < 0) if (get_oid(mergetag_data->argv[i], &oid) < 0)
return error(_("not a valid object name: '%s'"), return error(_("not a valid object name: '%s'"),
mergetag_data->argv[i]); mergetag_data->argv[i]);
if (!oidcmp(&tag->tagged->oid, &oid)) if (oideq(&tag->tagged->oid, &oid))
return 0; /* found */ return 0; /* found */
} }
...@@ -474,7 +474,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle) ...@@ -474,7 +474,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
strbuf_release(&buf); strbuf_release(&buf);
if (!oidcmp(&old_oid, &new_oid)) { if (oideq(&old_oid, &new_oid)) {
if (gentle) { if (gentle) {
warning(_("graft for '%s' unnecessary"), oid_to_hex(&old_oid)); warning(_("graft for '%s' unnecessary"), oid_to_hex(&old_oid));
return 0; return 0;
......
...@@ -180,7 +180,7 @@ static int check_local_mod(struct object_id *head, int index_only) ...@@ -180,7 +180,7 @@ static int check_local_mod(struct object_id *head, int index_only)
if (no_head if (no_head
|| get_tree_entry(head, name, &oid, &mode) || get_tree_entry(head, name, &oid, &mode)
|| ce->ce_mode != create_ce_mode(mode) || ce->ce_mode != create_ce_mode(mode)
|| oidcmp(&ce->oid, &oid)) || !oideq(&ce->oid, &oid))
staged_changes = 1; staged_changes = 1;
/* /*
......
...@@ -412,7 +412,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid, ...@@ -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 /* If both heads/foo and tags/foo exists, get_sha1 would
* get confused. * get confused.
*/ */
if (get_oid(refname + ofs, &tmp) || oidcmp(&tmp, oid)) if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
ofs = 5; ofs = 5;
return append_ref(refname + ofs, oid, 0); return append_ref(refname + ofs, oid, 0);
} }
...@@ -427,7 +427,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid, ...@@ -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 /* If both heads/foo and tags/foo exists, get_sha1 would
* get confused. * get confused.
*/ */
if (get_oid(refname + ofs, &tmp) || oidcmp(&tmp, oid)) if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
ofs = 5; ofs = 5;
return append_ref(refname + ofs, oid, 0); return append_ref(refname + ofs, oid, 0);
} }
...@@ -485,7 +485,7 @@ static void snarf_refs(int head, int remotes) ...@@ -485,7 +485,7 @@ static void snarf_refs(int head, int remotes)
static int rev_is_head(const char *head, const char *name, static int rev_is_head(const char *head, const char *name,
unsigned char *head_sha1, unsigned char *sha1) 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; return 0;
skip_prefix(head, "refs/heads/", &head); skip_prefix(head, "refs/heads/", &head);
if (!skip_prefix(name, "refs/heads/", &name)) if (!skip_prefix(name, "refs/heads/", &name))
......
...@@ -559,7 +559,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) ...@@ -559,7 +559,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
ref_transaction_commit(transaction, &err)) ref_transaction_commit(transaction, &err))
die("%s", err.buf); die("%s", err.buf);
ref_transaction_free(transaction); 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, printf(_("Updated tag '%s' (was %s)\n"), tag,
find_unique_abbrev(&prev, DEFAULT_ABBREV)); find_unique_abbrev(&prev, DEFAULT_ABBREV));
......
...@@ -303,7 +303,7 @@ static void added_object(unsigned nr, enum object_type type, ...@@ -303,7 +303,7 @@ static void added_object(unsigned nr, enum object_type type,
struct delta_info *info; struct delta_info *info;
while ((info = *p) != NULL) { 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) { info->base_offset == obj_list[nr].offset) {
*p = info->next; *p = info->next;
p = &delta_list; p = &delta_list;
...@@ -579,7 +579,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix) ...@@ -579,7 +579,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
if (fsck_finish(&fsck_options)) if (fsck_finish(&fsck_options))
die(_("fsck error in pack objects")); 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"); die("final sha1 did not match");