summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-09-17 20:53:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-09-17 20:53:57 (GMT)
commit769af0fd9ea0b4de172b51ae4b9ea41b57c02fd3 (patch)
tree524c7d9759fb9deae7b82581aa28fc8bc38265f6 /sequencer.c
parentd88949d86eddb62acbc85c16c97587db043d05b1 (diff)
parentd9f62dfa0ddc31bdad93054acca9fd42ca781f7f (diff)
downloadgit-769af0fd9ea0b4de172b51ae4b9ea41b57c02fd3.zip
git-769af0fd9ea0b4de172b51ae4b9ea41b57c02fd3.tar.gz
git-769af0fd9ea0b4de172b51ae4b9ea41b57c02fd3.tar.bz2
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
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/sequencer.c b/sequencer.c
index 9ba873b..00cefd1 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -614,7 +614,7 @@ static int is_index_unchanged(void)
if (!(cache_tree_oid = get_cache_tree_oid()))
return -1;
- return !oidcmp(cache_tree_oid, get_commit_tree_oid(head_commit));
+ return oideq(cache_tree_oid, get_commit_tree_oid(head_commit));
}
static int write_author_script(const char *message)
@@ -1221,7 +1221,7 @@ static int parse_head(struct commit **head)
current_head = lookup_commit_reference(the_repository, &oid);
if (!current_head)
return error(_("could not parse HEAD"));
- if (oidcmp(&oid, &current_head->object.oid)) {
+ if (!oideq(&oid, &current_head->object.oid)) {
warning(_("HEAD %s is not a commit!"),
oid_to_hex(&oid));
}
@@ -1291,9 +1291,9 @@ static int try_to_commit(struct strbuf *msg, const char *author,
goto out;
}
- if (!(flags & ALLOW_EMPTY) && !oidcmp(current_head ?
- get_commit_tree_oid(current_head) :
- the_hash_algo->empty_tree, &tree)) {
+ if (!(flags & ALLOW_EMPTY) && oideq(current_head ?
+ get_commit_tree_oid(current_head) :
+ the_hash_algo->empty_tree, &tree)) {
res = 1; /* run 'git commit' to display error message */
goto out;
}
@@ -1398,7 +1398,7 @@ static int is_original_commit_empty(struct commit *commit)
ptree_oid = the_hash_algo->empty_tree; /* commit is root */
}
- return !oidcmp(ptree_oid, get_commit_tree_oid(commit));
+ return oideq(ptree_oid, get_commit_tree_oid(commit));
}
/*
@@ -1678,7 +1678,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
unborn = get_oid("HEAD", &head);
/* Do we want to generate a root commit? */
if (is_pick_or_similar(command) && opts->have_squash_onto &&
- !oidcmp(&head, &opts->squash_onto)) {
+ oideq(&head, &opts->squash_onto)) {
if (is_fixup(command))
return error(_("cannot fixup root commit"));
flags |= CREATE_ROOT_COMMIT;
@@ -1721,7 +1721,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
oid_to_hex(&commit->object.oid));
if (opts->allow_ff && !is_fixup(command) &&
- ((parent && !oidcmp(&parent->object.oid, &head)) ||
+ ((parent && oideq(&parent->object.oid, &head)) ||
(!parent && unborn))) {
if (is_rebase_i(opts))
write_author_script(msg.message);
@@ -2426,7 +2426,7 @@ static int rollback_is_safe(void)
if (get_oid("HEAD", &actual_head))
oidclr(&actual_head);
- return !oidcmp(&actual_head, &expected_head);
+ return oideq(&actual_head, &expected_head);
}
static int reset_for_rollback(const struct object_id *oid)
@@ -2987,7 +2987,7 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
}
if (opts->have_squash_onto &&
- !oidcmp(&head_commit->object.oid, &opts->squash_onto)) {
+ oideq(&head_commit->object.oid, &opts->squash_onto)) {
/*
* When the user tells us to "merge" something into a
* "[new root]", let's simply fast-forward to the merge head.
@@ -3056,8 +3056,8 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
* commit, we cannot fast-forward.
*/
can_fast_forward = opts->allow_ff && commit && commit->parents &&
- !oidcmp(&commit->parents->item->object.oid,
- &head_commit->object.oid);
+ oideq(&commit->parents->item->object.oid,
+ &head_commit->object.oid);
/*
* If any merge head is different from the original one, we cannot
@@ -3067,7 +3067,7 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
struct commit_list *p = commit->parents->next;
for (j = to_merge; j && p; j = j->next, p = p->next)
- if (oidcmp(&j->item->object.oid,
+ if (!oideq(&j->item->object.oid,
&p->item->object.oid)) {
can_fast_forward = 0;
break;
@@ -3135,8 +3135,8 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
write_message("no-ff", 5, git_path_merge_mode(the_repository), 0);
bases = get_merge_bases(head_commit, merge_commit);
- if (bases && !oidcmp(&merge_commit->object.oid,
- &bases->item->object.oid)) {
+ if (bases && oideq(&merge_commit->object.oid,
+ &bases->item->object.oid)) {
ret = 0;
/* skip merging an ancestor of HEAD */
goto leave_merge;
@@ -3382,9 +3382,9 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
*/
if (item->command == TODO_REWORD &&
!get_oid("HEAD", &oid) &&
- (!oidcmp(&item->commit->object.oid, &oid) ||
+ (oideq(&item->commit->object.oid, &oid) ||
(opts->have_squash_onto &&
- !oidcmp(&opts->squash_onto, &oid))))
+ oideq(&opts->squash_onto, &oid))))
to_amend = 1;
return res | error_with_patch(item->commit,
@@ -3599,7 +3599,7 @@ static int commit_staged_changes(struct replay_opts *opts,
if (get_oid_hex(rev.buf, &to_amend))
return error(_("invalid contents: '%s'"),
rebase_path_amend());
- if (!is_clean && oidcmp(&head, &to_amend))
+ if (!is_clean && !oideq(&head, &to_amend))
return error(_("\nYou have uncommitted changes in your "
"working tree. Please, commit them\n"
"first and then run 'git rebase "
@@ -3611,7 +3611,7 @@ static int commit_staged_changes(struct replay_opts *opts,
* the commit message and if there was a squash, let the user
* edit it.
*/
- if (is_clean && !oidcmp(&head, &to_amend) &&
+ if (is_clean && oideq(&head, &to_amend) &&
opts->current_fixup_count > 0 &&
file_exists(rebase_path_stopped_sha())) {
const char *p = opts->current_fixups.buf;
@@ -4578,7 +4578,7 @@ int skip_unnecessary_picks(void)
if (item->commit->parents->next)
break; /* merge commit */
parent_oid = &item->commit->parents->item->object.oid;
- if (hashcmp(parent_oid->hash, oid->hash))
+ if (!oideq(parent_oid, oid))
break;
oid = &item->commit->object.oid;
}