diff options
Diffstat (limited to 'ranger/vcs/git.py')
-rw-r--r-- | ranger/vcs/git.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ranger/vcs/git.py b/ranger/vcs/git.py index 9df27b39..b2e79a06 100644 --- a/ranger/vcs/git.py +++ b/ranger/vcs/git.py @@ -35,6 +35,15 @@ class Git(Vcs): return self._vcs(path, 'git', args, silent=silent, catchout=catchout, bytes=bytes) + def _has_head(self): + """Checks whether repo has head""" + try: + self._git(self.path, ['rev-parse', 'HEAD'], silent=True) + except VcsError: + return False + return True + + def _head_ref(self): """Gets HEAD's ref""" ref = self._git(self.path, ['symbolic-ref', self.HEAD], catchout=True, silent=True) @@ -230,11 +239,13 @@ class Git(Vcs): def get_log(self, filelist=None, maxres=None): """Get the entire log for the current HEAD""" + if not self._has_head(): return [] return self._log(refspec=None, maxres=maxres, filelist=filelist) def get_raw_log(self, filelist=None): """Gets the raw log as a string""" + if not self._has_head(): return [] args = ['log'] if filelist: args = args + ['--'] + filelist return self._git(self.path, args, catchout=True) @@ -278,6 +289,7 @@ class Git(Vcs): """Gets info about the given revision rev""" if rev == None: rev = self.HEAD rev = self._sanitize_rev(rev) + if rev == self.HEAD and not self._has_head(): return None L = self._log(refspec=rev) if len(L) == 0: |