diff mbox series

[WIP,RFC,2/7] dir-iterator: use stat() instead of lstat()

Message ID 20190226002625.13022-3-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series clone: dir iterator refactoring with tests | expand

Commit Message

Ævar Arnfjörð Bjarmason Feb. 26, 2019, 12:26 a.m. UTC
This is surely a horrible idea, but all tests pass with this (not that
I trust them much). Doing this for later WIP use in clone.c.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 dir-iterator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matheus Tavares Feb. 26, 2019, 1:53 a.m. UTC | #1
On Mon, Feb 25, 2019 at 9:26 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> This is surely a horrible idea, but all tests pass with this (not that
> I trust them much). Doing this for later WIP use in clone.c.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  dir-iterator.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/dir-iterator.c b/dir-iterator.c
> index 070a656555..6a9c0c4d08 100644
> --- a/dir-iterator.c
> +++ b/dir-iterator.c
> @@ -149,7 +149,7 @@ int dir_iterator_advance(struct dir_iterator *dir_iterator)
>                                 continue;
>
>                         strbuf_addstr(&iter->base.path, de->d_name);
> -                       if (lstat(iter->base.path.buf, &iter->base.st) < 0) {
> +                       if (stat(iter->base.path.buf, &iter->base.st) < 0) {

I think this may have side-effects on other sections that uses the
dir-iterator API, because now it would follow symlinks, right?

>                                 if (errno != ENOENT) {
>                                         if (iter->pedantic)
>                                                 goto error_out;
> --
> 2.21.0.rc2.1.g2d5e20a900.dirty
>
diff mbox series

Patch

diff --git a/dir-iterator.c b/dir-iterator.c
index 070a656555..6a9c0c4d08 100644
--- a/dir-iterator.c
+++ b/dir-iterator.c
@@ -149,7 +149,7 @@  int dir_iterator_advance(struct dir_iterator *dir_iterator)
 				continue;
 
 			strbuf_addstr(&iter->base.path, de->d_name);
-			if (lstat(iter->base.path.buf, &iter->base.st) < 0) {
+			if (stat(iter->base.path.buf, &iter->base.st) < 0) {
 				if (errno != ENOENT) {
 					if (iter->pedantic)
 						goto error_out;