]> git.ipfire.org Git - thirdparty/git.git/commitdiff
dir: minor refactoring / clean-up
authorGoss Geppert <ggossdev@gmail.com>
Thu, 16 Jun 2022 23:44:33 +0000 (23:44 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Jun 2022 05:47:33 +0000 (22:47 -0700)
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>
dir.c

diff --git a/dir.c b/dir.c
index 0fd5912b398e62e56a67208204b5e75274c1cd23..4166d1b16a90e23017820c8caac0bbf2a24b0245 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1861,7 +1861,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
         */
        enum path_treatment state;
        int matches_how = 0;
-       int nested_repo = 0, check_only, stop_early;
+       int check_only, stop_early;
        int old_ignored_nr, old_untracked_nr;
        /* The "len-1" is to strip the final '/' */
        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,
                 *    manually configured by the user; see t2205 testcases 1-3 for
                 *    examples where this matters
                 */
+               int nested_repo;
                struct strbuf sb = STRBUF_INIT;
                strbuf_addstr(&sb, dirname);
                nested_repo = is_nonbare_repository_dir(&sb);
@@ -1916,12 +1917,13 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
                        free(real_dirname);
                }
                strbuf_release(&sb);
-       }
-       if (nested_repo) {
-               if ((dir->flags & DIR_SKIP_NESTED_GIT) ||
-                   (matches_how == MATCHED_RECURSIVELY_LEADING_PATHSPEC))
-                       return path_none;
-               return excluded ? path_excluded : path_untracked;
+
+               if (nested_repo) {
+                       if ((dir->flags & DIR_SKIP_NESTED_GIT) ||
+                               (matches_how == MATCHED_RECURSIVELY_LEADING_PATHSPEC))
+                               return path_none;
+                       return excluded ? path_excluded : path_untracked;
+               }
        }
 
        if (!(dir->flags & DIR_SHOW_OTHER_DIRECTORIES)) {