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 <ggossdev@gmail.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Goss Geppert committed Jun 16, 2022 at 23:44 UTC d6c9a717558a5ec36516026e68dcad3cbc4df1ff
1 file changed +9 -7
dir.c
+9 -7
@@ -1861,7 +1861,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
1861 */
1862 enum path_treatment state;
1863 int matches_how = 0;
1864 - int nested_repo = 0, check_only, stop_early;
1864 + int check_only, stop_early;
1865 int old_ignored_nr, old_untracked_nr;
1866 /* The "len-1" is to strip the final '/' */
1867 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,
1901 * manually configured by the user; see t2205 testcases 1-3 for
1902 * examples where this matters
1903 */
1904 + int nested_repo;
1905 struct strbuf sb = STRBUF_INIT;
1906 strbuf_addstr(&sb, dirname);
1907 nested_repo = is_nonbare_repository_dir(&sb);
@@ -1916,12 +1917,13 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
1917 free(real_dirname);
1918 }
1919 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 + }
1927 }
1928
1929 if (!(dir->flags & DIR_SHOW_OTHER_DIRECTORIES)) {