diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-07-01 12:51:27 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-07-01 12:32:22 -0700 |
commit | ce93a4c6127abdf1ad9eacd537edd1c571a18e41 (patch) | |
tree | f5393dbc3f3ce9cd98ba2aa5d7f015b1bd796a30 /builtin/stash.c | |
parent | *.c *_init(): define in terms of corresponding *_INIT macro (diff) | |
download | tgif-ce93a4c6127abdf1ad9eacd537edd1c571a18e41.tar.xz |
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 <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/stash.c')
-rw-r--r-- | builtin/stash.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/builtin/stash.c b/builtin/stash.c index 01066d7085..dc50a4b292 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -991,9 +991,8 @@ static int get_untracked_files(const struct pathspec *ps, int include_untracked, { int i; int found = 0; - struct dir_struct dir; + struct dir_struct dir = DIR_INIT; - dir_init(&dir); if (include_untracked != INCLUDE_ALL_FILES) setup_standard_excludes(&dir); |