Thread (18 messages) 18 messages, 3 authors, 2016-06-15

[PATCH v3 07/11] dir: add new_untracked_cache()

flat view
STALE3777d SUPERSEDED

From: Christian Couder <hidden>
Date: 2016-06-15 23:07:33
Subsystem: the rest · Maintainer: Linus Torvalds

Revision v3 of 9 in this series.

Revisions (9)
  1. rfc [diff vs current]
  2. v1 [diff vs current]
  3. v2 [diff vs current]
  4. v3 current
  5. v4 [diff vs current]
  6. v5 [diff vs current]
  7. v6 [diff vs current]
  8. v7 [diff vs current]
  9. v8 [diff vs current]
    Factor out code into new_untracked_cache(), which will be used
    multiple times in a later commit.

Signed-off-by: Christian Couder <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help