dir: traverse into repository
commit27128996b88f3dd0624324f8eb9648c0754cfa20
authorGoss Geppert <ggossdev@gmail.com>
Thu, 16 Jun 2022 23:19:55 +0000 (16 23:19 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Jun 2022 05:47:33 +0000 (21 22:47 -0700)
treee8637f0c41193f7627d4247b8a058b4f9d74ba2a
parent6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e
dir: traverse into repository

Since 8d92fb2927 (dir: replace exponential algorithm with a linear one,
2020-04-01) traversing into a repository's directory tree when the
traversal began outside the repository's standard location has failed
because the encountered repository was identified as a nested foreign
repository.

Prior to this commit, the failure to traverse into a repository's
default worktree location was observable from a user's perspective under
either of the following conditions (there may be others):

    1) Set the `core.worktree` location to a parent directory of the
       default worktree; or
    2) Use the `--git_dir` option while the working directory is outside
       the repository's default worktree location

Under either of these conditions, symptoms of the failure to traverse
into the repository's default worktree location include the inability to
add files to the index or get a list of untracked files via ls-files.

This commit adds a check to determine whether a nested repository that
is encountered in recursing a path is actually `the_repository`.  If so,
we simply treat the directory as if it doesn't contain a nested
repository.

The commit includes test-cases to reduce the likelihood of future
regressions.

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
t/t2205-add-worktree-config.sh [new file with mode: 0755]