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>
Brandon Williams committed
May 5, 2017 at 12:53 UTC
ae520e36758f45f1b9972f2b91db91a7f1c5559e
1 file changed
+12
-10
dir.c
+12
-10
@@ -1264,14 +1264,15 @@ enum exist_status {
1264
* the directory name; instead, use the case insensitive
1265
* directory hash.
1266
*/
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)
1269
{
1270
struct cache_entry *ce;
1271
1271
- if (index_dir_exists(&the_index, dirname, len))
1272
+ if (index_dir_exists(istate, dirname, len))
1273
return index_directory;
1274
1274
- ce = index_file_exists(&the_index, dirname, len, ignore_case);
1275
+ ce = index_file_exists(istate, dirname, len, ignore_case);
1276
if (ce && S_ISGITLINK(ce->ce_mode))
1277
return index_gitdir;
1278
@@ -1285,18 +1286,19 @@ static enum exist_status directory_exists_in_index_icase(const char *dirname, in
1286
* the files it contains) will sort with the '/' at the
1287
* end.
1288
*/
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)
1291
{
1292
int pos;
1293
1294
if (ignore_case)
1293
- return directory_exists_in_index_icase(dirname, len);
1295
+ return directory_exists_in_index_icase(istate, dirname, len);
1296
1295
- pos = index_name_pos(&the_index, dirname, len);
1297
+ pos = index_name_pos(istate, dirname, len);
1298
if (pos < 0)
1299
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++];
1302
unsigned char endchar;
1303
1304
if (strncmp(ce->name, dirname, len))
@@ -1351,7 +1353,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
1353
const struct pathspec *pathspec)
1354
{
1355
/* 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)) {
1357
case index_directory:
1358
return path_recurse;
1359
@@ -1554,7 +1556,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
1556
if ((dir->flags & DIR_COLLECT_KILLED_ONLY) &&
1557
(dtype == DT_DIR) &&
1558
!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))
1560
return path_none;
1561
1562
exclude = is_excluded(dir, path->buf, &dtype);