Skip to content

Commit ae520e3

Browse files
bmwillgitster
authored andcommitted
dir: convert directory_exists_in_index to take index
Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6f52b74 commit ae520e3

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

dir.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,14 +1264,15 @@ enum exist_status {
12641264
* the directory name; instead, use the case insensitive
12651265
* directory hash.
12661266
*/
1267-
static enum exist_status directory_exists_in_index_icase(const char *dirname, int len)
1267+
static enum exist_status directory_exists_in_index_icase(struct index_state *istate,
1268+
const char *dirname, int len)
12681269
{
12691270
struct cache_entry *ce;
12701271

1271-
if (index_dir_exists(&the_index, dirname, len))
1272+
if (index_dir_exists(istate, dirname, len))
12721273
return index_directory;
12731274

1274-
ce = index_file_exists(&the_index, dirname, len, ignore_case);
1275+
ce = index_file_exists(istate, dirname, len, ignore_case);
12751276
if (ce && S_ISGITLINK(ce->ce_mode))
12761277
return index_gitdir;
12771278

@@ -1285,18 +1286,19 @@ static enum exist_status directory_exists_in_index_icase(const char *dirname, in
12851286
* the files it contains) will sort with the '/' at the
12861287
* end.
12871288
*/
1288-
static enum exist_status directory_exists_in_index(const char *dirname, int len)
1289+
static enum exist_status directory_exists_in_index(struct index_state *istate,
1290+
const char *dirname, int len)
12891291
{
12901292
int pos;
12911293

12921294
if (ignore_case)
1293-
return directory_exists_in_index_icase(dirname, len);
1295+
return directory_exists_in_index_icase(istate, dirname, len);
12941296

1295-
pos = index_name_pos(&the_index, dirname, len);
1297+
pos = index_name_pos(istate, dirname, len);
12961298
if (pos < 0)
12971299
pos = -pos-1;
1298-
while (pos < the_index.cache_nr) {
1299-
const struct cache_entry *ce = the_index.cache[pos++];
1300+
while (pos < istate->cache_nr) {
1301+
const struct cache_entry *ce = istate->cache[pos++];
13001302
unsigned char endchar;
13011303

13021304
if (strncmp(ce->name, dirname, len))
@@ -1351,7 +1353,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
13511353
const struct pathspec *pathspec)
13521354
{
13531355
/* The "len-1" is to strip the final '/' */
1354-
switch (directory_exists_in_index(dirname, len-1)) {
1356+
switch (directory_exists_in_index(&the_index, dirname, len-1)) {
13551357
case index_directory:
13561358
return path_recurse;
13571359

@@ -1554,7 +1556,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
15541556
if ((dir->flags & DIR_COLLECT_KILLED_ONLY) &&
15551557
(dtype == DT_DIR) &&
15561558
!has_path_in_index &&
1557-
(directory_exists_in_index(path->buf, path->len) == index_nonexistent))
1559+
(directory_exists_in_index(&the_index, path->buf, path->len) == index_nonexistent))
15581560
return path_none;
15591561

15601562
exclude = is_excluded(dir, path->buf, &dtype);

0 commit comments

Comments
 (0)