Resolve symlinks at get_branch_name

Fixes #1958. Instead of attempting to resolve at each vcs module, the
get_branch_name always uses the realpath to cache branch names.
This commit is contained in:
BK Bolisetty 2019-10-17 16:15:19 -05:00
parent 8c8959e5b2
commit e090bff7ad
2 changed files with 4 additions and 3 deletions

View File

@ -9,7 +9,7 @@ from collections import defaultdict
from powerline.lib.watcher import create_tree_watcher
from powerline.lib.unicode import out_u
from powerline.lib.path import join
from powerline.lib.path import join, realpath
def generate_directories(path):
@ -53,6 +53,8 @@ file_status_lock = Lock()
def get_branch_name(directory, config_file, get_func, create_watcher):
global branch_name_cache
with branch_lock:
# Remove any symlinks (if any) along the path
directory = realpath(directory)
# Check if the repo directory was moved/deleted
fw = branch_watcher(create_watcher)
is_watched = fw.is_watching(directory)

View File

@ -6,7 +6,7 @@ import re
from powerline.lib.vcs import get_branch_name, get_file_status
from powerline.lib.shell import readlines
from powerline.lib.path import join, realpath
from powerline.lib.path import join
from powerline.lib.encoding import (get_preferred_file_name_encoding,
get_preferred_file_contents_encoding)
from powerline.lib.shell import which
@ -86,7 +86,6 @@ class GitRepository(object):
def branch(self):
directory = git_directory(self.directory)
head = join(directory, 'HEAD')
directory = realpath(directory)
return get_branch_name(
directory=directory,
config_file=head,