Skip to content

Commit 07b29bf

Browse files
chriscoolgitster
authored andcommitted
dir: add remove_untracked_cache()
Factor out code into remove_untracked_cache(), which will be used in a later commit. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a4ca47 commit 07b29bf

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

builtin/update-index.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,11 +1126,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
11261126
add_untracked_cache(&the_index);
11271127
report(_("Untracked cache enabled for '%s'"), get_git_work_tree());
11281128
} else if (untracked_cache == UC_DISABLE) {
1129-
if (the_index.untracked) {
1130-
free_untracked_cache(the_index.untracked);
1131-
the_index.untracked = NULL;
1132-
the_index.cache_changed |= UNTRACKED_CHANGED;
1133-
}
1129+
remove_untracked_cache(&the_index);
11341130
report(_("Untracked cache disabled"));
11351131
}
11361132

dir.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,15 @@ void add_untracked_cache(struct index_state *istate)
19561956
istate->cache_changed |= UNTRACKED_CHANGED;
19571957
}
19581958

1959+
void remove_untracked_cache(struct index_state *istate)
1960+
{
1961+
if (istate->untracked) {
1962+
free_untracked_cache(istate->untracked);
1963+
istate->untracked = NULL;
1964+
istate->cache_changed |= UNTRACKED_CHANGED;
1965+
}
1966+
}
1967+
19591968
static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *dir,
19601969
int base_len,
19611970
const struct pathspec *pathspec)

dir.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,4 +309,5 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long
309309
void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked);
310310
void add_untracked_ident(struct untracked_cache *);
311311
void add_untracked_cache(struct index_state *istate);
312+
void remove_untracked_cache(struct index_state *istate);
312313
#endif

0 commit comments

Comments
 (0)