Factor out code into new_untracked_cache(), which will be used multiple times in a later commit. Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx> --- dir.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/dir.c b/dir.c index 0f7e293..4227ba6 100644 --- a/dir.c +++ b/dir.c @@ -1938,16 +1938,20 @@ void add_untracked_ident(struct untracked_cache *uc) strbuf_addch(&uc->ident, 0); } +static void new_untracked_cache(void) +{ + struct untracked_cache *uc = xcalloc(1, sizeof(*uc)); + strbuf_init(&uc->ident, 100); + uc->exclude_per_dir = ".gitignore"; + /* should be the same flags used by git-status */ + uc->dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES; + the_index.untracked = uc; +} + void add_untracked_cache(void) { - if (!the_index.untracked) { - struct untracked_cache *uc = xcalloc(1, sizeof(*uc)); - strbuf_init(&uc->ident, 100); - uc->exclude_per_dir = ".gitignore"; - /* should be the same flags used by git-status */ - uc->dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES; - the_index.untracked = uc; - } + if (!the_index.untracked) + new_untracked_cache(); add_untracked_ident(the_index.untracked); the_index.cache_changed |= UNTRACKED_CHANGED; } -- 2.7.0.rc2.11.g68ccdd4 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html