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

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

flat view

From: Eric Sunshine <hidden>
Date: 2016-06-15 23:07:33

On Wed, Dec 23, 2015 at 4:03 PM, Christian Couder
[off-list ref] wrote:
    Factor out code into new_untracked_cache(), which will be used
    multiple times in a later commit.
Odd indentation: s/^\s+//
quoted hunk ↗ jump to hunk
Signed-off-by: Christian Couder <redacted>
---
diff --git 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;
+}
This and the previous patch both move the same code around. As a
reviewer, I could easily see the two patches combined, and would not
find the unified patch onerous to review.
 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