[PATCH 05/10] dir.[ch]: make DIR_INIT mandatory
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-10-04 00:46:39
Subsystem:
the rest · Maintainer:
Linus Torvalds
The dir_init() initializer has been documented as being mandatory since eceba532141 (dir: fix problematic API to avoid memory leaks, 2020-08-18), but both it and my ce93a4c6127 (dir.[ch]: replace dir_init() with DIR_INIT, 2021-07-01) managed to miss this callsite in "add-interactive.c" added before those two commits in ab1e1cccaf6 (built-in add -i: re-implement `add-untracked` in C, 2019-11-29). In addition my change to remove dir_init() neglected to update this documentation. Let's use "must be initialized with" in reference to "DIR_INIT". We have one lazy initialization which pre-dates eceba532141 in dir.c. Adjusting this callsite is a prerequisite for removing it in favor of trusting the macro to initialize the "struct dir_struct" correctly. Signed-off-by: Ævar Arnfjörð Bjarmason <redacted> --- add-interactive.c | 2 +- dir.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/add-interactive.c b/add-interactive.c
index 6498ae196f1..27daea8d1b3 100644
--- a/add-interactive.c
+++ b/add-interactive.c@@ -826,7 +826,7 @@ static int get_untracked_files(struct repository *r, struct prefix_item_list *files, const struct pathspec *ps) { - struct dir_struct dir = { 0 }; + struct dir_struct dir = DIR_INIT; size_t i; struct strbuf buf = STRBUF_INIT;
diff --git a/dir.h b/dir.h
index 83f46c0fb4c..ff3b4a7f602 100644
--- a/dir.h
+++ b/dir.h@@ -19,7 +19,7 @@ * CE_SKIP_WORKTREE marked. If you want to exclude files, make sure you have * loaded the index first. * - * - Prepare `struct dir_struct dir` using `dir_init()` function. + * - The `struct dir_struct dir` must be initialized with `DIR_INIT`. * * - To add single exclude pattern, call `add_pattern_list()` and then * `add_pattern()`.
--
2.33.0.1404.g83021034c5d