Skip to content

Commit

Permalink
Optimistically fill the repo_path cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste committed Nov 27, 2024
1 parent 25b7c74 commit e501465
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 e501465

Please sign in to comment.