path: root/builtin/check-ignore.c
diff options
authorÆvar Arnfjörð Bjarmason <>2021-07-01 10:51:27 (GMT)
committerJunio C Hamano <>2021-07-01 19:32:22 (GMT)
commitce93a4c6127abdf1ad9eacd537edd1c571a18e41 (patch)
treef5393dbc3f3ce9cd98ba2aa5d7f015b1bd796a30 /builtin/check-ignore.c
parent5726a6b4012cd41701927a6637b9f2070e7760ee (diff)
dir.[ch]: replace dir_init() with DIR_INIT
Remove the dir_init() function and replace it with a DIR_INIT macro. In many cases in the codebase we need to initialize things with a function for good reasons, e.g. needing to call another function on initialization. The "dir_init()" function was not one such case, and could trivially be replaced with a more idiomatic macro initialization pattern. The only place where we made use of its use of memset() was in dir_clear() itself, which resets the contents of an an existing struct pointer. Let's use the new "memcpy() a 'blank' struct on the stack" idiom to do that reset. Signed-off-by: Ævar Arnfjörð Bjarmason <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/check-ignore.c')
1 files changed, 1 insertions, 2 deletions
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index 8123455..2191256 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -153,7 +153,7 @@ static int check_ignore_stdin_paths(struct dir_struct *dir, const char *prefix)
int cmd_check_ignore(int argc, const char **argv, const char *prefix)
int num_ignored;
- struct dir_struct dir;
+ struct dir_struct dir = DIR_INIT;
git_config(git_default_config, NULL);
@@ -182,7 +182,6 @@ int cmd_check_ignore(int argc, const char **argv, const char *prefix)
if (!no_index && read_cache() < 0)
die(_("index file corrupt"));
- dir_init(&dir);
if (stdin_paths) {