Skip to content

Commit cc82ad7

Browse files
Goss Geppertgitster
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]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8562fc8 commit cc82ad7

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
@@ -1874,7 +1874,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
18741874
*/
18751875
enum path_treatment state;
18761876
int matches_how = 0;
1877-
int nested_repo = 0, check_only, stop_early;
1877+
int check_only, stop_early;
18781878
int old_ignored_nr, old_untracked_nr;
18791879
/* The "len-1" is to strip the final '/' */
18801880
enum exist_status status = directory_exists_in_index(istate, dirname, len-1);
@@ -1914,6 +1914,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
19141914
* manually configured by the user; see t2205 testcases 1-3 for
19151915
* examples where this matters
19161916
*/
1917+
int nested_repo;
19171918
struct strbuf sb = STRBUF_INIT;
19181919
strbuf_addstr(&sb, dirname);
19191920
nested_repo = is_nonbare_repository_dir(&sb);
@@ -1929,12 +1930,13 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
19291930
free(real_dirname);
19301931
}
19311932
strbuf_release(&sb);
1932-
}
1933-
if (nested_repo) {
1934-
if ((dir->flags & DIR_SKIP_NESTED_GIT) ||
1935-
(matches_how == MATCHED_RECURSIVELY_LEADING_PATHSPEC))
1936-
return path_none;
1937-
return excluded ? path_excluded : path_untracked;
1933+
1934+
if (nested_repo) {
1935+
if ((dir->flags & DIR_SKIP_NESTED_GIT) ||
1936+
(matches_how == MATCHED_RECURSIVELY_LEADING_PATHSPEC))
1937+
return path_none;
1938+
return excluded ? path_excluded : path_untracked;
1939+
}
19381940
}
19391941

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

0 commit comments

Comments
 (0)