Skip to content

Commit d6c9a71

Browse files
Goss Geppertgitster
Goss Geppert
authored andcommitted
dir: minor refactoring / clean-up
Narrow the scope of the `nested_repo` variable and conditional return statement to the block where the variable is set. Signed-off-by: Goss Geppert <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2712899 commit d6c9a71

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

dir.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
18611861
*/
18621862
enum path_treatment state;
18631863
int matches_how = 0;
1864-
int nested_repo = 0, check_only, stop_early;
1864+
int check_only, stop_early;
18651865
int old_ignored_nr, old_untracked_nr;
18661866
/* The "len-1" is to strip the final '/' */
18671867
enum exist_status status = directory_exists_in_index(istate, dirname, len-1);
@@ -1901,6 +1901,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
19011901
* manually configured by the user; see t2205 testcases 1-3 for
19021902
* examples where this matters
19031903
*/
1904+
int nested_repo;
19041905
struct strbuf sb = STRBUF_INIT;
19051906
strbuf_addstr(&sb, dirname);
19061907
nested_repo = is_nonbare_repository_dir(&sb);
@@ -1916,12 +1917,13 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
19161917
free(real_dirname);
19171918
}
19181919
strbuf_release(&sb);
1919-
}
1920-
if (nested_repo) {
1921-
if ((dir->flags & DIR_SKIP_NESTED_GIT) ||
1922-
(matches_how == MATCHED_RECURSIVELY_LEADING_PATHSPEC))
1923-
return path_none;
1924-
return excluded ? path_excluded : path_untracked;
1920+
1921+
if (nested_repo) {
1922+
if ((dir->flags & DIR_SKIP_NESTED_GIT) ||
1923+
(matches_how == MATCHED_RECURSIVELY_LEADING_PATHSPEC))
1924+
return path_none;
1925+
return excluded ? path_excluded : path_untracked;
1926+
}
19251927
}
19261928

19271929
if (!(dir->flags & DIR_SHOW_OTHER_DIRECTORIES)) {

0 commit comments

Comments
 (0)