Skip to content

Commit c3e95ab

Browse files
authored
Merge pull request #1959 from timbrel/opt-repo-cache
Optimistically fill the `repo_path` cache
2 parents 25b7c74 + e501465 commit c3e95ab

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

core/git_command.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,17 @@ def _find_git_toplevel(self, folder):
681681
repo_path = search_for_git_toplevel(folder)
682682
if repo_path:
683683
util.debug.dprint("repo path:", os.path.join(repo_path, ".git"))
684-
repo_paths[folder] = repo_path
684+
# Check if we followed links, as `paths_upwards` is only a string operation,
685+
# then fill the cache upwards.
686+
if folder.startswith(repo_path):
687+
for p in paths_upwards(folder):
688+
if p in repo_paths:
689+
break
690+
repo_paths[p] = repo_path
691+
if p == repo_path:
692+
break
693+
else:
694+
repo_paths[folder] = repo_path
685695
else:
686696
util.debug.dprint("found no .git path for {}".format(folder))
687697
return repo_path

0 commit comments

Comments
 (0)