diff --git a/dir.c b/dir.c index 39fce3bcba705f..efc87c2e405468 100644 --- a/dir.c +++ b/dir.c @@ -1550,14 +1550,6 @@ static void prep_exclude(struct dir_struct *dir, if (dir->pattern) return; - /* - * Lazy initialization. All call sites currently just - * memset(dir, 0, sizeof(*dir)) before use. Changing all of - * them seems lots of work for little benefit. - */ - if (!dir->basebuf.buf) - strbuf_init(&dir->basebuf, PATH_MAX); - /* Read from the parent directories and push them down. */ current = stk ? stk->baselen : -1; strbuf_setlen(&dir->basebuf, current < 0 ? 0 : current); diff --git a/dir.h b/dir.h index 83f46c0fb4c441..048a091cd8e610 100644 --- a/dir.h +++ b/dir.h @@ -342,7 +342,9 @@ struct dir_struct { unsigned visited_directories; }; -#define DIR_INIT { 0 } +#define DIR_INIT { \ + .basebuf = STRBUF_INIT, \ +} struct dirent *readdir_skip_dot_and_dotdot(DIR *dirp); diff --git a/unpack-trees.h b/unpack-trees.h index 6fa6a4dfc3e450..b181860ce6e960 100644 --- a/unpack-trees.h +++ b/unpack-trees.h @@ -92,6 +92,7 @@ struct unpack_trees_options { struct checkout_metadata meta; }; #define UNPACK_TREES_OPTIONS_INIT { \ + .msgs_to_free = STRVEC_INIT, \ .dir = DIR_INIT, \ }