diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-02-21 13:37:19 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-02-21 18:58:05 +0100 |
commit | 0218de2bdbd13975c31c3944775d0d7a6cd73e7b (patch) | |
tree | f59db946484f6176fcd73e1bdc66458a09da687c /dir-iterator.c | |
parent | Merge branch 'ps/reftable-backend' into ps/reflog-list (diff) | |
download | git-0218de2bdbd13975c31c3944775d0d7a6cd73e7b.tar.xz git-0218de2bdbd13975c31c3944775d0d7a6cd73e7b.zip |
dir-iterator: pass name to `prepare_next_entry_data()` directly
When adding the next directory entry for `struct dir_iterator` we pass
the complete `struct dirent *` to `prepare_next_entry_data()` even
though we only need the entry's name.
Refactor the code to pass in the name, only. This prepares for a
subsequent commit where we introduce the ability to iterate through
dir entries in an ordered manner.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir-iterator.c')
-rw-r--r-- | dir-iterator.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/dir-iterator.c b/dir-iterator.c index 278b04243a..f58a97e089 100644 --- a/dir-iterator.c +++ b/dir-iterator.c @@ -94,15 +94,15 @@ static int pop_level(struct dir_iterator_int *iter) /* * Populate iter->base with the necessary information on the next iteration - * entry, represented by the given dirent de. Return 0 on success and -1 + * entry, represented by the given name. Return 0 on success and -1 * otherwise, setting errno accordingly. */ static int prepare_next_entry_data(struct dir_iterator_int *iter, - struct dirent *de) + const char *name) { int err, saved_errno; - strbuf_addstr(&iter->base.path, de->d_name); + strbuf_addstr(&iter->base.path, name); /* * We have to reset these because the path strbuf might have * been realloc()ed at the previous strbuf_addstr(). @@ -159,7 +159,7 @@ int dir_iterator_advance(struct dir_iterator *dir_iterator) if (is_dot_or_dotdot(de->d_name)) continue; - if (prepare_next_entry_data(iter, de)) { + if (prepare_next_entry_data(iter, de->d_name)) { if (errno != ENOENT && iter->flags & DIR_ITERATOR_PEDANTIC) goto error_out; continue; |