From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 08/15] merge-recursive.c: stop using index compat macros
Date: Sat, 16 Jun 2018 07:41:50 +0200 [thread overview]
Message-ID: <20180616054157.32433-9-pclouds@gmail.com> (raw)
In-Reply-To: <20180616054157.32433-1-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
merge-recursive.c | 65 ++++++++++++++++++++++++-----------------------
1 file changed, 33 insertions(+), 32 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index 5eb907f46e..2a9dfe3b33 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -319,7 +319,7 @@ static int add_cacheinfo(struct merge_options *o,
if (!ce)
return err(o, _("add_cacheinfo failed for path '%s'; merge aborting."), path);
- ret = add_cache_entry(ce, options);
+ ret = add_index_entry(&the_index, ce, options);
if (refresh) {
struct cache_entry *nce;
@@ -327,7 +327,7 @@ static int add_cacheinfo(struct merge_options *o,
if (!nce)
return err(o, _("add_cacheinfo failed to refresh for path '%s'; merge aborting."), path);
if (nce != ce)
- ret = add_cache_entry(nce, options);
+ ret = add_index_entry(&the_index, nce, options);
}
return ret;
}
@@ -365,7 +365,7 @@ static int unpack_trees_start(struct merge_options *o,
init_tree_desc_from_tree(t+2, merge);
rc = unpack_trees(3, t, &o->unpack_opts);
- cache_tree_free(&active_cache_tree);
+ cache_tree_free(&the_index.cache_tree);
/*
* Update the_index to match the new results, AFTER saving a copy
@@ -390,11 +390,11 @@ struct tree *write_tree_from_memory(struct merge_options *o)
{
struct tree *result = NULL;
- if (unmerged_cache()) {
+ if (unmerged_index(&the_index)) {
int i;
fprintf(stderr, "BUG: There are unmerged index entries:\n");
- for (i = 0; i < active_nr; i++) {
- const struct cache_entry *ce = active_cache[i];
+ for (i = 0; i < the_index.cache_nr; i++) {
+ const struct cache_entry *ce = the_index.cache[i];
if (ce_stage(ce))
fprintf(stderr, "BUG: %d %.*s\n", ce_stage(ce),
(int)ce_namelen(ce), ce->name);
@@ -402,16 +402,16 @@ struct tree *write_tree_from_memory(struct merge_options *o)
BUG("unmerged index entries in merge-recursive.c");
}
- if (!active_cache_tree)
- active_cache_tree = cache_tree();
+ if (!the_index.cache_tree)
+ the_index.cache_tree = cache_tree();
- if (!cache_tree_fully_valid(active_cache_tree) &&
+ if (!cache_tree_fully_valid(the_index.cache_tree) &&
cache_tree_update(&the_index, 0) < 0) {
err(o, _("error building trees"));
return NULL;
}
- result = lookup_tree(&active_cache_tree->oid);
+ result = lookup_tree(&the_index.cache_tree->oid);
return result;
}
@@ -488,10 +488,10 @@ static struct string_list *get_unmerged(void)
unmerged->strdup_strings = 1;
- for (i = 0; i < active_nr; i++) {
+ for (i = 0; i < the_index.cache_nr; i++) {
struct string_list_item *item;
struct stage_data *e;
- const struct cache_entry *ce = active_cache[i];
+ const struct cache_entry *ce = the_index.cache[i];
if (!ce_stage(ce))
continue;
@@ -651,7 +651,7 @@ static int update_stages(struct merge_options *opt, const char *path,
int clear = 1;
int options = ADD_CACHE_OK_TO_ADD | ADD_CACHE_SKIP_DFCHECK;
if (clear)
- if (remove_file_from_cache(path))
+ if (remove_file_from_index(&the_index, path))
return -1;
if (o)
if (add_cacheinfo(opt, o->mode, &o->oid, path, 1, 0, options))
@@ -707,13 +707,14 @@ static int remove_file(struct merge_options *o, int clean,
int update_working_directory = !o->call_depth && !no_wd;
if (update_cache) {
- if (remove_file_from_cache(path))
+ if (remove_file_from_index(&the_index, path))
return -1;
}
if (update_working_directory) {
if (ignore_case) {
struct cache_entry *ce;
- ce = cache_file_exists(path, strlen(path), ignore_case);
+ ce = index_file_exists(&the_index, path, strlen(path),
+ ignore_case);
if (ce && ce_stage(ce) == 0 && strcmp(path, ce->name))
return 0;
}
@@ -772,12 +773,12 @@ static int dir_in_way(const char *path, int check_working_copy, int empty_ok)
strbuf_addstr(&dirpath, path);
strbuf_addch(&dirpath, '/');
- pos = cache_name_pos(dirpath.buf, dirpath.len);
+ pos = index_name_pos(&the_index, dirpath.buf, dirpath.len);
if (pos < 0)
pos = -1 - pos;
- if (pos < active_nr &&
- !strncmp(dirpath.buf, active_cache[pos]->name, dirpath.len)) {
+ if (pos < the_index.cache_nr &&
+ !strncmp(dirpath.buf, the_index.cache[pos]->name, dirpath.len)) {
strbuf_release(&dirpath);
return 1;
}
@@ -839,19 +840,19 @@ static int would_lose_untracked(const char *path)
* update_file()/would_lose_untracked(); see every comment in this
* file which mentions "update_stages".
*/
- int pos = cache_name_pos(path, strlen(path));
+ int pos = index_name_pos(&the_index, path, strlen(path));
if (pos < 0)
pos = -1 - pos;
- while (pos < active_nr &&
- !strcmp(path, active_cache[pos]->name)) {
+ while (pos < the_index.cache_nr &&
+ !strcmp(path, the_index.cache[pos]->name)) {
/*
* If stage #0, it is definitely tracked.
* If it has stage #2 then it was tracked
* before this merge started. All other
* cases the path was not tracked.
*/
- switch (ce_stage(active_cache[pos])) {
+ switch (ce_stage(the_index.cache[pos])) {
case 0:
case 2:
return 0;
@@ -1466,7 +1467,7 @@ static int handle_change_delete(struct merge_options *o,
* correct; since there is no true "middle point" between
* them, simply reuse the base version for virtual merge base.
*/
- ret = remove_file_from_cache(path);
+ ret = remove_file_from_index(&the_index, path);
if (!ret)
ret = update_file(o, 0, o_oid, o_mode, update_path);
} else {
@@ -1527,7 +1528,7 @@ static int conflict_rename_delete(struct merge_options *o,
return -1;
if (o->call_depth)
- return remove_file_from_cache(dest->path);
+ return remove_file_from_index(&the_index, dest->path);
else
return update_stages(o, dest->path, NULL,
rename_branch == o->branch1 ? dest : NULL,
@@ -1662,14 +1663,14 @@ static int conflict_rename_rename_1to2(struct merge_options *o,
return -1;
}
else
- remove_file_from_cache(a->path);
+ remove_file_from_index(&the_index, a->path);
add = filespec_from_entry(&other, ci->dst_entry2, 3 ^ 1);
if (add) {
if (update_file(o, 0, &add->oid, add->mode, b->path))
return -1;
}
else
- remove_file_from_cache(b->path);
+ remove_file_from_index(&the_index, b->path);
} else if (handle_file(o, a, 2, ci) || handle_file(o, b, 3, ci))
return -1;
@@ -3063,7 +3064,7 @@ static int merge_content(struct merge_options *o,
if (df_conflict_remains || is_dirty) {
char *new_path;
if (o->call_depth) {
- remove_file_from_cache(path);
+ remove_file_from_index(&the_index, path);
} else {
if (!mfi.clean) {
if (update_stages(o, path, &one, &a, &b))
@@ -3220,7 +3221,7 @@ static int process_entry(struct merge_options *o,
if (update_file(o, 0, oid, mode, new_path))
clean_merge = -1;
else if (o->call_depth)
- remove_file_from_cache(path);
+ remove_file_from_index(&the_index, path);
free(new_path);
} else {
output(o, 2, _("Adding %s"), path);
@@ -3284,7 +3285,7 @@ int merge_trees(struct merge_options *o,
return -1;
}
- if (unmerged_cache()) {
+ if (unmerged_index(&the_index)) {
struct string_list *entries;
struct rename_info re_info;
int i;
@@ -3415,7 +3416,7 @@ int merge_recursive(struct merge_options *o,
* overwritten it: the committed "conflicts" were
* already resolved.
*/
- discard_cache();
+ discard_index(&the_index);
saved_b1 = o->branch1;
saved_b2 = o->branch2;
o->branch1 = "Temporary merge branch 1";
@@ -3431,9 +3432,9 @@ int merge_recursive(struct merge_options *o,
return err(o, _("merge returned no commit"));
}
- discard_cache();
+ discard_index(&the_index);
if (!o->call_depth)
- read_cache();
+ read_index(&the_index);
o->ancestor = "merged common ancestors";
clean = merge_trees(o, get_commit_tree(h1), get_commit_tree(h2),
--
2.18.0.rc0.333.g22e6ee6cdf
next prev parent reply other threads:[~2018-06-16 5:42 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-16 5:41 [PATCH 00/15] Kill the_index part 1, expose it Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` [PATCH 01/15] contrib: add cocci script to replace index compat macros Nguyễn Thái Ngọc Duy
2018-06-19 11:35 ` Derrick Stolee
2018-06-19 11:41 ` Derrick Stolee
2018-06-19 14:51 ` Duy Nguyen
2018-06-19 15:21 ` Derrick Stolee
2018-07-23 12:56 ` SZEDER Gábor
2018-06-16 5:41 ` [PATCH 02/15] apply.c: stop using " Nguyễn Thái Ngọc Duy
2018-06-25 17:27 ` Junio C Hamano
2018-06-30 8:38 ` Duy Nguyen
2018-07-03 18:30 ` Junio C Hamano
2018-07-09 14:35 ` Duy Nguyen
2018-06-16 5:41 ` [PATCH 03/15] blame.c: " Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` [PATCH 04/15] check-racy.c: " Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` [PATCH 05/15] diff-lib.c: " Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` [PATCH 06/15] diff.c: " Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` [PATCH 07/15] entry.c: " Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` Nguyễn Thái Ngọc Duy [this message]
2018-06-16 5:41 ` [PATCH 09/15] merge.c: " Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` [PATCH 10/15] rerere.c: " Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` [PATCH 11/15] revision.c: " Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` [PATCH 12/15] sequencer.c: " Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` [PATCH 13/15] sha1-name.c: " Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` [PATCH 14/15] wt-status.c: " Nguyễn Thái Ngọc Duy
2018-06-16 5:41 ` [PATCH 15/15] cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch Nguyễn Thái Ngọc Duy
2018-06-18 18:53 ` Brandon Williams
2018-06-17 7:02 ` [PATCH 00/15] Kill the_index part 1, expose it Elijah Newren
2018-06-17 8:49 ` Duy Nguyen
2018-06-18 18:41 ` Brandon Williams
2018-06-19 19:00 ` Ben Peart
2018-06-19 11:48 ` Derrick Stolee
2018-06-19 14:48 ` Duy Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180616054157.32433-9-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.