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 11/24] unpack-trees: convert clear_ce_flags* to avoid the_index
Date: Mon, 13 Aug 2018 18:14:28 +0200 [thread overview]
Message-ID: <20180813161441.16824-12-pclouds@gmail.com> (raw)
In-Reply-To: <20180813161441.16824-1-pclouds@gmail.com>
Prior to fba92be8f7, this code implicitly (and incorrectly) assumes
the_index when running the exclude machinery. fba92be8f7 helps show
this problem clearer because unpack-trees operation is supposed to
work on whatever index the caller specifies... not specifically
the_index.
Update the code to use "istate" argument that's originally from
mark_new_skip_worktree(). From the call sites, both in unpack_trees(),
you can see that this function works on two separate indexes:
o->src_index and o->result. The second mark_new_skip_worktree() so far
has incorecctly applied exclude rules on o->src_index instead of
o->result. It's unclear what is the consequences of this, but it's
definitely wrong.
[1] fba92be8f7 (dir: convert is_excluded_from_list to take an index -
2017-05-05)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
unpack-trees.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index f50b463f65..5d11f10e66 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1092,13 +1092,15 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
return mask;
}
-static int clear_ce_flags_1(struct cache_entry **cache, int nr,
+static int clear_ce_flags_1(struct index_state *istate,
+ struct cache_entry **cache, int nr,
struct strbuf *prefix,
int select_mask, int clear_mask,
struct exclude_list *el, int defval);
/* Whole directory matching */
-static int clear_ce_flags_dir(struct cache_entry **cache, int nr,
+static int clear_ce_flags_dir(struct index_state *istate,
+ struct cache_entry **cache, int nr,
struct strbuf *prefix,
char *basename,
int select_mask, int clear_mask,
@@ -1107,7 +1109,7 @@ static int clear_ce_flags_dir(struct cache_entry **cache, int nr,
struct cache_entry **cache_end;
int dtype = DT_DIR;
int ret = is_excluded_from_list(prefix->buf, prefix->len,
- basename, &dtype, el, &the_index);
+ basename, &dtype, el, istate);
int rc;
strbuf_addch(prefix, '/');
@@ -1129,7 +1131,7 @@ static int clear_ce_flags_dir(struct cache_entry **cache, int nr,
* calling clear_ce_flags_1(). That function will call
* the expensive is_excluded_from_list() on every entry.
*/
- rc = clear_ce_flags_1(cache, cache_end - cache,
+ rc = clear_ce_flags_1(istate, cache, cache_end - cache,
prefix,
select_mask, clear_mask,
el, ret);
@@ -1152,7 +1154,8 @@ static int clear_ce_flags_dir(struct cache_entry **cache, int nr,
* cache[0]->name[0..(prefix_len-1)]
* Top level path has prefix_len zero.
*/
-static int clear_ce_flags_1(struct cache_entry **cache, int nr,
+static int clear_ce_flags_1(struct index_state *istate,
+ struct cache_entry **cache, int nr,
struct strbuf *prefix,
int select_mask, int clear_mask,
struct exclude_list *el, int defval)
@@ -1186,7 +1189,7 @@ static int clear_ce_flags_1(struct cache_entry **cache, int nr,
len = slash - name;
strbuf_add(prefix, name, len);
- processed = clear_ce_flags_dir(cache, cache_end - cache,
+ processed = clear_ce_flags_dir(istate, cache, cache_end - cache,
prefix,
prefix->buf + prefix->len - len,
select_mask, clear_mask,
@@ -1200,7 +1203,7 @@ static int clear_ce_flags_1(struct cache_entry **cache, int nr,
}
strbuf_addch(prefix, '/');
- cache += clear_ce_flags_1(cache, cache_end - cache,
+ cache += clear_ce_flags_1(istate, cache, cache_end - cache,
prefix,
select_mask, clear_mask, el, defval);
strbuf_setlen(prefix, prefix->len - len - 1);
@@ -1210,7 +1213,7 @@ static int clear_ce_flags_1(struct cache_entry **cache, int nr,
/* Non-directory */
dtype = ce_to_dtype(ce);
ret = is_excluded_from_list(ce->name, ce_namelen(ce),
- name, &dtype, el, &the_index);
+ name, &dtype, el, istate);
if (ret < 0)
ret = defval;
if (ret > 0)
@@ -1220,15 +1223,17 @@ static int clear_ce_flags_1(struct cache_entry **cache, int nr,
return nr - (cache_end - cache);
}
-static int clear_ce_flags(struct cache_entry **cache, int nr,
- int select_mask, int clear_mask,
- struct exclude_list *el)
+static int clear_ce_flags(struct index_state *istate,
+ int select_mask, int clear_mask,
+ struct exclude_list *el)
{
static struct strbuf prefix = STRBUF_INIT;
strbuf_reset(&prefix);
- return clear_ce_flags_1(cache, nr,
+ return clear_ce_flags_1(istate,
+ istate->cache,
+ istate->cache_nr,
&prefix,
select_mask, clear_mask,
el, 0);
@@ -1263,7 +1268,7 @@ static void mark_new_skip_worktree(struct exclude_list *el,
* 2. Widen worktree according to sparse-checkout file.
* Matched entries will have skip_wt_flag cleared (i.e. "in")
*/
- clear_ce_flags(istate->cache, istate->cache_nr, select_flag, skip_wt_flag, el);
+ clear_ce_flags(istate, select_flag, skip_wt_flag, el);
}
static int verify_absent(const struct cache_entry *,
--
2.18.0.1004.g6639190530
next prev parent reply other threads:[~2018-08-13 16:15 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 16:14 [PATCH 00/24] Kill the_index part3 Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 01/24] diff.c: move read_index() code back to the caller Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 02/24] cache-tree: wrap the_index based wrappers with #ifdef Nguyễn Thái Ngọc Duy
2018-08-13 21:18 ` Junio C Hamano
2018-08-13 16:14 ` [PATCH 03/24] attr: remove an implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-08-13 17:12 ` Brandon Williams
2018-08-13 16:14 ` [PATCH 04/24] convert.c: " Nguyễn Thái Ngọc Duy
2018-08-13 21:21 ` Junio C Hamano
2018-08-13 16:14 ` [PATCH 05/24] dir.c: remove an implicit dependency on the_index in pathspec code Nguyễn Thái Ngọc Duy
2018-08-13 17:17 ` Brandon Williams
2018-08-13 18:40 ` Duy Nguyen
2018-08-13 16:14 ` [PATCH 06/24] preload-index.c: use the right index instead of the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 07/24] ls-files: correct index argument to get_convert_attr_ascii() Nguyễn Thái Ngọc Duy
2018-08-15 18:56 ` Stefan Beller
2018-08-13 16:14 ` [PATCH 08/24] unpack-trees: remove 'extern' on function declaration Nguyễn Thái Ngọc Duy
2018-08-15 19:10 ` Stefan Beller
2018-08-15 19:21 ` Duy Nguyen
2018-08-15 19:25 ` Stefan Beller
2018-08-13 16:14 ` [PATCH 09/24] unpack-trees: add a note about path invalidation Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 10/24] unpack-trees: don't shadow global var the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` Nguyễn Thái Ngọc Duy [this message]
2018-08-13 16:14 ` [PATCH 12/24] unpack-trees: avoid the_index in verify_absent() Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 13/24] pathspec.c: use the right index instead of the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 14/24] submodule.c: " Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 15/24] entry.c: " Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 16/24] attr: remove index from git_attr_set_direction() Nguyễn Thái Ngọc Duy
2018-08-13 17:22 ` Brandon Williams
2018-08-13 16:14 ` [PATCH 17/24] grep: use the right index instead of the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 18/24] archive.c: avoid access to the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 19/24] archive-*.c: use the right repository Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 20/24] resolve-undo.c: use the right index instead of the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 21/24] apply.c: pass struct apply_state to more functions Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 22/24] apply.c: make init_apply_state() take a struct repository Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 23/24] apply.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 24/24] blame.c: " Nguyễn Thái Ngọc Duy
2018-08-13 17:28 ` [PATCH 00/24] Kill the_index part3 Brandon Williams
2018-08-13 21:24 ` Junio C Hamano
2018-08-15 19:48 ` Stefan Beller
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=20180813161441.16824-12-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).