diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2022-11-19 13:07:38 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-11-21 03:06:15 (GMT) |
commit | 07047d68294769d5e8700fc200ac326a21d04f8e (patch) | |
tree | 127e54f371d37d63ee8920d25bba062a8cd30ceb /builtin/merge.c | |
parent | bdafeae0b9cdbf5b33c116564ffec93389cc5d37 (diff) | |
download | git-07047d68294769d5e8700fc200ac326a21d04f8e.zip git-07047d68294769d5e8700fc200ac326a21d04f8e.tar.gz git-07047d68294769d5e8700fc200ac326a21d04f8e.tar.bz2 |
cocci: apply "pending" index-compatibility to some "builtin/*.c"
Apply "index-compatibility.pending.cocci" rule to "builtin/*", but
exclude those where we conflict with in-flight changes.
As a result some of them end up using only "the_index", so let's have
them use the more narrow "USE_THE_INDEX_VARIABLE" rather than
"USE_THE_INDEX_COMPATIBILITY_MACROS".
Manual changes not made by coccinelle, that were squashed in:
* Whitespace-wrap argument lists for repo_hold_locked_index(),
repo_read_index_preload() and repo_refresh_and_write_index(), in cases
where the line became too long after the transformation.
* Change "refresh_cache()" to "refresh_index()" in a comment in
"builtin/update-index.c".
* For those whose call was followed by perror("<macro-name>"), change
it to perror("<function-name>"), referring to the new function.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/merge.c')
-rw-r--r-- | builtin/merge.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/builtin/merge.c b/builtin/merge.c index 27218ee..dd47437 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -318,7 +318,7 @@ static int save_state(struct object_id *stash) int rc = -1; fd = repo_hold_locked_index(the_repository, &lock_file, 0); - refresh_cache(REFRESH_QUIET); + refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL); if (0 <= fd) repo_update_index_if_able(the_repository, &lock_file); rollback_lock_file(&lock_file); @@ -716,7 +716,9 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, { const char *head_arg = "HEAD"; - if (refresh_and_write_cache(REFRESH_QUIET, SKIP_IF_UNCHANGED, 0) < 0) + if (repo_refresh_and_write_index(the_repository, REFRESH_QUIET, + SKIP_IF_UNCHANGED, 0, NULL, NULL, + NULL) < 0) return error(_("Unable to write index.")); if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree") || @@ -750,7 +752,8 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, for (j = common; j; j = j->next) commit_list_insert(j->item, &reversed); - hold_locked_index(&lock, LOCK_DIE_ON_ERROR); + repo_hold_locked_index(the_repository, &lock, + LOCK_DIE_ON_ERROR); if (!strcmp(strategy, "ort")) clean = merge_ort_recursive(&o, head, remoteheads->item, reversed, &result); @@ -859,9 +862,9 @@ static void prepare_to_commit(struct commit_list *remoteheads) * the editor and after we invoke run_status above. */ if (invoked_hook) - discard_cache(); + discard_index(&the_index); } - read_cache_from(index_file); + read_index_from(&the_index, index_file, get_git_dir()); strbuf_addbuf(&msg, &merge_msg); if (squash) BUG("the control must not reach here under --squash"); @@ -910,7 +913,9 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads) struct object_id result_tree, result_commit; struct commit_list *parents, **pptr = &parents; - if (refresh_and_write_cache(REFRESH_QUIET, SKIP_IF_UNCHANGED, 0) < 0) + if (repo_refresh_and_write_index(the_repository, REFRESH_QUIET, + SKIP_IF_UNCHANGED, 0, NULL, NULL, + NULL) < 0) return error(_("Unable to write index.")); write_tree_trivial(&result_tree); @@ -1602,7 +1607,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) * We are not doing octopus, not fast-forward, and have * only one common. */ - refresh_cache(REFRESH_QUIET); + refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL); if (allow_trivial && fast_forward != FF_ONLY) { /* * Must first ensure that index matches HEAD before |