Skip to content

Commit

Permalink
Pass through the git_root_dir, if present
Browse files Browse the repository at this point in the history
Otherwise the file > blame > commit sequence breaks.
  • Loading branch information
kemayo committed Feb 1, 2016
1 parent 22b02d9 commit 66e7426
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 13 additions & 7 deletions git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ def quick_panel(self, *args, **kwargs):
def record_git_root_to_view(self, view):
# Store the git root directory in the view so we can resolve relative paths
# when the user wants to navigate to the source file.
view.settings().set("git_root_dir", git_root(self.get_working_dir()))
if self.get_working_dir():
root = git_root(self.get_working_dir())
else:
root = self.active_view().settings().get("git_root_dir")
view.settings().set("git_root_dir", root)


# A base for all git commands that work with the entire repository
Expand Down Expand Up @@ -359,11 +363,10 @@ def get_working_dir(self):
file_name = self._active_file_name()
if file_name:
return os.path.realpath(os.path.dirname(file_name))
else:
try: # handle case with no open folder
return self.window.folders()[0]
except IndexError:
return ''
try: # handle case with no open folder
return self.window.folders()[0]
except IndexError:
return ''

def get_window(self):
return self.window
Expand All @@ -390,7 +393,10 @@ def get_relative_file_name(self):
return file_name.replace('\\', '/') # windows issues

def get_working_dir(self):
return os.path.realpath(os.path.dirname(self.view.file_name()))
file_name = self.view.file_name()
if file_name:
return os.path.realpath(os.path.dirname(file_name))
return ''

def get_window(self):
# Fun discovery: if you switch tabs while a command is working,
Expand Down
4 changes: 1 addition & 3 deletions git/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def get_lines(self):
def blame_done(self, result, position=None):
view = self.scratch(result, title="Git Blame", position=position,
syntax=plugin_file("syntax/Git Blame.tmLanguage"))
# store working dir to be potentially used by the GitGotoCommit command
view.settings().set("git_working_dir", self.get_working_dir())


class GitLog(object):
Expand Down Expand Up @@ -239,7 +237,7 @@ def run(self, edit):
commit = line.split(" ")[0]
if not commit or commit == "00000000":
return
working_dir = view.settings().get("git_working_dir")
working_dir = view.settings().get("git_root_dir")
self.run_command(['git', 'show', commit], self.show_done, working_dir=working_dir)

def show_done(self, result):
Expand Down

0 comments on commit 66e7426

Please sign in to comment.