Commit 4a7e27e9 authored by Jeff King's avatar Jeff King Committed by Junio C Hamano

convert "oidcmp() == 0" to oideq()

Using the more restrictive oideq() should, in the long run,
give the compiler more opportunities to optimize these
callsites. For now, this conversion should be a complete
noop with respect to the generated code.

The result is also perhaps a little more readable, as it
avoids the "zero is equal" idiom. Since it's so prevalent in
C, I think seasoned programmers tend not to even notice it
anymore, but it can sometimes make for awkward double
negations (e.g., we can drop a few !!oidcmp() instances
here).

This patch was generated almost entirely by the included
coccinelle patch. This mechanical conversion should be
completely safe, because we check explicitly for cases where
oidcmp() is compared to 0, which is what oideq() is doing
under the hood. Note that we don't have to catch "!oidcmp()"
separately; coccinelle's standard isomorphisms make sure the
two are treated equivalently.

I say "almost" because I did hand-edit the coccinelle output
to fix up a few style violations (it mostly keeps the
original formatting, but sometimes unwraps long lines).
Signed-off-by: default avatarJeff King <peff@peff.net>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent 14438c44
......@@ -807,7 +807,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;
......@@ -988,7 +988,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;
}
......
......@@ -2077,7 +2077,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"
......
......@@ -96,7 +96,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;
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -507,7 +507,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();
......@@ -644,7 +644,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);
......
......@@ -582,7 +582,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;
......
......@@ -992,7 +992,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;
......@@ -1703,7 +1703,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))
return 0;
}
get_patch_ids(&rev, &ids);
......@@ -1949,7 +1949,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;
}
......
......@@ -1189,7 +1189,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;
......@@ -1448,7 +1448,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;
......
......@@ -1202,7 +1202,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;
}
......@@ -1384,7 +1384,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;
}
......
......@@ -799,7 +799,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");
......
......@@ -1222,8 +1222,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;
......
......@@ -412,7 +412,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;
......
......@@ -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;
......
......@@ -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 */
......
......@@ -714,7 +714,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;
}
......@@ -1100,7 +1100,7 @@ static inline int is_empty_blob_sha1(const unsigned char *sha1)
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)
......@@ -1110,7 +1110,7 @@ static inline int is_empty_tree_sha1(const unsigned char *sha1)
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;
}
......
......@@ -779,7 +779,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]);
......
......@@ -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)
......
......@@ -108,3 +108,9 @@ expression E1, E2;
@@
- hashcpy(E1.hash, E2->hash)
+ oidcpy(&E1, E2)
@@
expression E1, E2;
@@
- oidcmp(E1, E2) == 0
+ oideq(E1, E2)
......@@ -366,7 +366,7 @@ static int show_modified(struct rev_info *revs,
}
oldmode = old_entry->ce_mode;
if (mode == oldmode && !oidcmp(oid, &old_entry->oid) && !dirty_submodule &&
if (mode == oldmode && oideq(oid, &old_entry->oid) && !dirty_submodule &&
!revs->diffopt.flags.find_copies_harder)
return 0;
......
......@@ -3404,7 +3404,7 @@ static void builtin_diff(const char *name_a,
if (!one->data && !two->data &&
S_ISREG(one->mode) && S_ISREG(two->mode) &&
!o->flags.binary) {
if (!oidcmp(&one->oid, &two->oid)) {
if (oideq(&one->oid, &two->oid)) {
if (must_show_header)
emit_diff_symbol(o, DIFF_SYMBOL_HEADER,
header.buf, header.len,
......@@ -3569,7 +3569,7 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
return;
}
same_contents = !oidcmp(&one->oid, &two->oid);
same_contents = oideq(&one->oid, &two->oid);
if (diff_filespec_is_binary(one) || diff_filespec_is_binary(two)) {
data->is_binary = 1;
......@@ -5323,7 +5323,7 @@ int diff_unmodified_pair(struct diff_filepair *p)
* dealing with a change.
*/
if (one->oid_valid && two->oid_valid &&
!oidcmp(&one->oid, &two->oid) &&
oideq(&one->oid, &two->oid) &&
!one->dirty_submodule && !two->dirty_submodule)
return 1; /* no change */
if (!one->oid_valid && !two->oid_valid)
......
......@@ -58,7 +58,7 @@ static int should_break(struct diff_filespec *src,
}
if (src->oid_valid && dst->oid_valid &&
!oidcmp(&src->oid, &dst->oid))
oideq(&src->oid, &dst->oid))
return 0; /* they are the same */
if (diff_populate_filespec(src, 0) || diff_populate_filespec(dst, 0))
......
......@@ -572,7 +572,7 @@ static struct object_entry *find_object(struct object_id *oid)
unsigned int h = oid->hash[0] << 8 | oid->hash[1];
struct object_entry *e;
for (e = object_table[h]; e; e = e->next)
if (!oidcmp(oid, &e->idx.oid))
if (oideq(oid, &e->idx.oid))
return e;
return NULL;
}
......@@ -583,7 +583,7 @@ static struct object_entry *insert_object(struct object_id *oid)
struct object_entry *e = object_table[h];
while (e) {
if (!oidcmp(oid, &e->idx.oid))
if (oideq(oid, &e->idx.oid))
return e;
e = e->next;
}
......@@ -1533,7 +1533,7 @@ static int tree_content_set(
if (!*slash1) {
if (!S_ISDIR(mode)
&& e->versions[1].mode == mode
&& !oidcmp(&e->versions[1].oid, oid))
&& oideq(&e->versions[1].oid, oid))
return 0;
e->versions[1].mode = mode;
oidcpy(&e->versions[1].oid, oid);
......
......@@ -1859,7 +1859,7 @@ int cmd_main(int argc, const char **argv)
continue;
}
if (!oidcmp(&ref->old_oid, &ref->peer_ref->new_oid)) {
if (oideq(&ref->old_oid, &ref->peer_ref->new_oid)) {
if (push_verbosely)
fprintf(stderr, "'%s': up-to-date\n", ref->name);
if (helper_status)
......
......@@ -472,7 +472,7 @@ static int which_parent(const struct object_id *oid, const struct commit *commit
const struct commit_list *parent;
for (nth = 0, parent = commit->parents; parent; parent = parent->next) {
if (!oidcmp(&parent->item->object.oid, oid))
if (oideq(&parent->item->object.oid, oid))
return nth;
nth++;
}
......@@ -506,8 +506,8 @@ static int show_one_mergetag(struct commit *commit,
if (parse_tag_buffer(the_repository, tag, extra->value, extra->len))
strbuf_addstr(&verify_message, "malformed mergetag\n");
else if (is_common_merge(commit) &&
!oidcmp(&tag->tagged->oid,
&commit->parents->next->item->object.oid))
oideq(&tag->tagged->oid,
&commit->parents->next->item->object.oid))
strbuf_addf(&verify_message,
"merged tag '%s'\n", tag->tag);
else if ((nth = which_parent(&tag->tagged->oid, commit)) < 0)
......
......@@ -156,7 +156,7 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two,
shift_tree_by(&one->object.oid, &two->object.oid, &shifted,
subtree_shift);
}
if (!oidcmp(&two->object.oid, &shifted))
if (oideq(&two->object.oid, &shifted))
return two;
return lookup_tree(the_repository, &shifted);
}
......@@ -179,7 +179,7 @@ static int oid_eq(const struct object_id *a, const struct object_id *b)
{
if (!a && !b)
return 2;
return a && b && oidcmp(a, b) == 0;
return a && b && oideq(a, b);
}
enum rename_type {
......
......@@ -151,7 +151,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
mp = find_notes_merge_pair_pos(changes, len, &obj, 1, &occupied);
if (occupied) {
/* We've found an addition/deletion pair */
assert(!oidcmp(&mp->obj, &obj));
assert(oideq(&mp->obj, &obj));
if (is_null_oid(&p->one->oid)) { /* addition */
assert(is_null_oid(&mp->remote));
oidcpy(&mp->remote, &p->two->oid);
......@@ -218,7 +218,7 @@ static void diff_tree_local(struct notes_merge_options *o,
continue;
}
assert(!oidcmp(&mp->obj, &obj));
assert(oideq(&mp->obj, &obj));
if (is_null_oid(&p->two->oid)) { /* deletion */
/*
* Either this is a true deletion (1), or it is part
......@@ -229,7 +229,7 @@ static void diff_tree_local(struct notes_merge_options *o,
* (3) mp->local is uninitialized; set it to null_sha1
* (will be overwritten by following addition)
*/
if (!oidcmp(&mp->local, &uninitialized))
if (oideq(&mp->local, &uninitialized))
oidclr(&mp->local);
} else if (is_null_oid(&p->one->oid)) { /* addition */
/*
......@@ -241,7 +241,7 @@ static void diff_tree_local(struct notes_merge_options *o,
* (3) mp->local is null_sha1; set to p->two->sha1
*/
assert(is_null_oid(&mp->local) ||
!oidcmp(&mp->local, &uninitialized));
oideq(&mp->local, &uninitialized));
oidcpy(&mp->local, &p->two->oid);
} else { /* modification */
/*
......@@ -249,8 +249,8 @@ static void diff_tree_local(struct notes_merge_options *o,
* match mp->base, and mp->local shall be uninitialized.
* Set mp->local to p->two->sha1.
*/
assert(!oidcmp(&p->one->oid, &mp->base));
assert(!oidcmp(&mp->local, &uninitialized));
assert(oideq(&p->one->oid, &mp->base));
assert(oideq(&mp->local, &uninitialized));
oidcpy(&mp->local, &p->two->oid);
}
trace_printf("\t\tStored local change for %s: %.7s -> %.7s\n",
......@@ -480,14 +480,14 @@ static int merge_changes(struct notes_merge_options *o,
oid_to_hex(&p->local),
oid_to_hex(&p->remote));
if (!oidcmp(&p->base, &p->remote)) {
if (oideq(&p->base, &p->remote)) {
/* no remote change; nothing to do */
trace_printf("\t\t\tskipping (no remote change)\n");
} else if (!oidcmp(&p->local, &p->remote)) {
} else if (oideq(&p->local, &p->remote)) {
/* same change in local and remote; nothing to do */
trace_printf("\t\t\tskipping (local == remote)\n");
} else if (!oidcmp(&p->local, &uninitialized) ||
!oidcmp(&p->local, &p->base)) {
} else if (oideq(&p->local, &uninitialized) ||
oideq(&p->local, &p->base)) {
/* no local change; adopt remote change */
trace_printf("\t\t\tno local change, adopted remote\n");
if (add_note(t, &p->obj, &p->remote,
......@@ -621,14 +621,14 @@ int notes_merge(struct notes_merge_options *o,
oid_to_hex(&local->object.oid),
oid_to_hex(base_oid));
if (!oidcmp(&remote->object.oid, base_oid)) {
if (oideq(&remote->object.oid, base_oid)) {
/* Already merged; result == local commit */
if (o->verbosity >= 2)
printf("Already up to date!\n");
oidcpy(result_oid, &local->object.oid);
goto found_result;
}
if (!oidcmp(&local->object.oid, base_oid)) {
if (oideq(&local->object.oid, base_oid)) {
/* Fast-forward; result == remote commit */
if (o->verbosity >= 2)
printf("Fast-forward\n");
......
......@@ -266,9 +266,9 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree,
case PTR_TYPE_NOTE:
switch (type) {
case PTR_TYPE_NOTE:
if (!oidcmp(&l->key_oid, &entry->key_oid)) {
if (oideq(&l->key_oid, &entry->key_oid)) {
/* skip concatenation if l == entry */
if (!oidcmp(&l->val_oid, &entry->val_oid))
if (oideq(&l->val_oid, &entry->val_oid))
return 0;
ret = combine_notes(&l->val_oid,
......
......@@ -124,7 +124,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
}
hashwrite(f, obj->oid.hash, the_hash_algo->rawsz);
if ((opts->flags & WRITE_IDX_STRICT) &&
(i && !oidcmp(&list[-2]->oid, &obj->oid)))
(i && oideq(&list[-2]->oid, &obj->oid)))
die("The same object %s appears twice in the pack",
oid_to_hex(&obj->oid));
}
......
......@@ -767,7 +767,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)
......
......@@ -1710,7 +1710,7 @@ struct contains_stack {
static int in_commit_list(const struct commit_list *want, struct commit *c)
{
for (; want; want = want->next)
if (!oidcmp(&want->item->object.oid, &c->object.oid))
if (oideq(&want->item->object.oid, &c->object.oid))
return 1;
return 0;
}
......
......@@ -2307,7 +2307,7 @@ static int check_old_oid(struct ref_update *update, struct object_id *oid,
struct strbuf *err)
{
if (!(update->flags & REF_HAVE_OLD) ||
!oidcmp(oid, &update->old_oid))
oideq(oid, &update->old_oid))
return 0;
if (is_null_oid(&update->old_oid))
......@@ -2443,7 +2443,7 @@ static int lock_ref_for_update(struct files_ref_store *refs,
!(update->flags & REF_DELETING) &&
!(update->flags & REF_LOG_ONLY)) {
if (!(update->type & REF_ISSYMREF) &&
!oidcmp(&lock->old_oid, &update->new_oid)) {
oideq(&lock->old_oid, &update->new_oid)) {
/*
* The reference already has the desired
* value, so we don't need to write it.
......
......@@ -1388,7 +1388,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
ref->deletion = is_null_oid(&ref->new_oid);
if (!ref->deletion &&
!oidcmp(&ref->old_oid, &ref->new_oid)) {
oideq(&ref->old_oid, &ref->new_oid)) {
ref->status = REF_STATUS_UPTODATE;
continue;
}
......@@ -2049,7 +2049,7 @@ struct ref *guess_remote_head(const struct ref *head,
/* If refs/heads/master could be right, it is. */
if (!all) {
r = find_ref_by_name(refs, "refs/heads/master");
if (r && !oidcmp(&r->old_oid, &head->old_oid))
if (r && oideq(&r->old_oid, &head->old_oid))
return copy_ref(r);
}
......@@ -2057,7 +2057,7 @@ struct ref *guess_remote_head(const struct ref *head,
for (r = refs; r; r = r->next) {
if (r != head &&
starts_with(r->name, "refs/heads/") &&
!oidcmp(&r->old_oid, &head->old_oid)) {
oideq(&r->old_oid, &head->old_oid)) {
*tail = copy_ref(r);
tail = &((*tail)->next);
if (!all)
......
......@@ -3238,7 +3238,7 @@ static void track_linear(struct rev_info *revs, struct commit *commit)
struct commit_list *p;
for (p = revs->previous_parents; p; p = p->next)
if (p->item