From: Christian Couder Date: Wed, 23 Dec 2015 21:03:55 GMT Subject: [PATCH v3 07/11] dir: add new_untracked_cache() Message-ID: <1450904639-25592-8-git-send-email-chriscool@tuxfamily.org> In-Reply-To: <1450904639-25592-1-git-send-email-chriscool@tuxfamily.org> Factor out code into new_untracked_cache(), which will be used multiple times in a later commit. Signed-off-by: Christian Couder --- 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