summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xranger/config/commands.py39
-rw-r--r--ranger/ext/vcs/vcs.py1
2 files changed, 19 insertions, 21 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 9aee9f29..b2c704c7 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -1336,18 +1336,16 @@ class stage(Command):
     def execute(self):
         from ranger.ext.vcs import VcsError
 
-        filelist = [f.path for f in self.fm.thistab.get_selection()]
-        self.fm.thisdir.vcs_outdated = True
-#        for f in self.fm.thistab.get_selection():
-#            f.vcs_outdated = True
-
-        try:
-            self.fm.thisdir.vcs.add(filelist)
-        except VcsError:
-            self.fm.notify("Could not stage files.")
-
-        self.fm.reload_cwd()
 
+        if self.fm.thisdir.vcs and self.fm.thisdir.vcs.track:
+            filelist = [f.path for f in self.fm.thistab.get_selection()]
+            try:
+                self.fm.thisdir.vcs.add(filelist)
+            except VcsError as error:
+                self.fm.notify('Unable to unstage files: {0:s}'.format(str(error)))
+            self.fm.reload_cwd()
+        else:
+            self.fm.notify('Unable to stage files: Not in repository')
 
 class unstage(Command):
     """
@@ -1358,17 +1356,16 @@ class unstage(Command):
     def execute(self):
         from ranger.ext.vcs import VcsError
 
-        filelist = [f.path for f in self.fm.thistab.get_selection()]
-        self.fm.thisdir.vcs_outdated = True
-#        for f in self.fm.thistab.get_selection():
-#            f.vcs_outdated = True
 
-        try:
-            self.fm.thisdir.vcs.reset(filelist)
-        except VcsError:
-            self.fm.notify("Could not unstage files.")
-
-        self.fm.reload_cwd()
+        if self.fm.thisdir.vcs and self.fm.thisdir.vcs.track:
+            filelist = [f.path for f in self.fm.thistab.get_selection()]
+            try:
+                self.fm.thisdir.vcs.reset(filelist)
+            except VcsError as error:
+                self.fm.notify('Unable to unstage files: {0:s}'.format(str(error)))
+            self.fm.reload_cwd()
+        else:
+            self.fm.notify('Unable to unstage files: Not in repository')
 
 
 class diff(Command):
diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py
index 9cf84663..5e9f03c1 100644
--- a/ranger/ext/vcs/vcs.py
+++ b/ranger/ext/vcs/vcs.py
@@ -107,6 +107,7 @@ class Vcs(object):
                     self.track = False
                     self.in_repodir = True
                 else:
+                    self.__class__ = self.rootvcs.__class__
                     self.track = self.rootvcs.track
                     self.in_repodir = False
         else: