Skip to content

Commit 02cb675

Browse files
pcloudsgitster
authored andcommitted
read_directory_recursive: reduce one indentation level
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5fb8c05 commit 02cb675

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

dir.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -968,34 +968,34 @@ static int read_directory_recursive(struct dir_struct *dir,
968968
{
969969
DIR *fdir = opendir(*base ? base : ".");
970970
int contents = 0;
971+
struct dirent *de;
972+
char path[PATH_MAX + 1];
971973

972-
if (fdir) {
973-
struct dirent *de;
974-
char path[PATH_MAX + 1];
975-
memcpy(path, base, baselen);
976-
977-
while ((de = readdir(fdir)) != NULL) {
978-
int len;
979-
switch (treat_path(dir, de, path, sizeof(path),
980-
baselen, simplify, &len)) {
981-
case path_recurse:
982-
contents += read_directory_recursive
983-
(dir, path, len, 0, simplify);
984-
continue;
985-
case path_ignored:
986-
continue;
987-
case path_handled:
988-
break;
989-
}
990-
contents++;
991-
if (check_only)
992-
goto exit_early;
993-
else
994-
dir_add_name(dir, path, len);
974+
if (!fdir)
975+
return 0;
976+
977+
memcpy(path, base, baselen);
978+
979+
while ((de = readdir(fdir)) != NULL) {
980+
int len;
981+
switch (treat_path(dir, de, path, sizeof(path),
982+
baselen, simplify, &len)) {
983+
case path_recurse:
984+
contents += read_directory_recursive(dir, path, len, 0, simplify);
985+
continue;
986+
case path_ignored:
987+
continue;
988+
case path_handled:
989+
break;
995990
}
996-
exit_early:
997-
closedir(fdir);
991+
contents++;
992+
if (check_only)
993+
goto exit_early;
994+
else
995+
dir_add_name(dir, path, len);
998996
}
997+
exit_early:
998+
closedir(fdir);
999999

10001000
return contents;
10011001
}

0 commit comments

Comments
 (0)