Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimistically fill the repo_path cache #1959

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion core/git_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,17 @@ def _find_git_toplevel(self, folder):
repo_path = search_for_git_toplevel(folder)
if repo_path:
util.debug.dprint("repo path:", os.path.join(repo_path, ".git"))
repo_paths[folder] = repo_path
# Check if we followed links, as `paths_upwards` is only a string operation,
# then fill the cache upwards.
if folder.startswith(repo_path):
for p in paths_upwards(folder):
if p in repo_paths:
break
repo_paths[p] = repo_path
if p == repo_path:
break
else:
repo_paths[folder] = repo_path
else:
util.debug.dprint("found no .git path for {}".format(folder))
return repo_path
Expand Down