Skip to content

Commit

Permalink
Merge pull request #1959 from timbrel/opt-repo-cache
Browse files Browse the repository at this point in the history
Optimistically fill the `repo_path` cache
  • Loading branch information
kaste authored Nov 27, 2024
2 parents 25b7c74 + e501465 commit c3e95ab
Showing 1 changed file with 11 additions and 1 deletion.
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

0 comments on commit c3e95ab

Please sign in to comment.