Don't check out files if we don't have index+workdir
authorKarl Hasselström <kha@treskal.com>
Sun, 10 Feb 2008 14:43:41 +0000 (15:43 +0100)
committerKarl Hasselström <kha@treskal.com>
Sun, 10 Feb 2008 14:46:36 +0000 (15:46 +0100)
It seems no one had tried to run a transaction without having an index
and a workdir, but this is exacly the situation we get when operating
on a stack other than the current one.

The fix is simple: don't try to check out.

Signed-off-by: Karl Hasselström <kha@treskal.com>
stgit/lib/transaction.py

index 6a2ed81..3613b15 100644 (file)
@@ -92,12 +92,13 @@ class StackTransaction(object):
         new_head = self.__head
 
         # Set branch head.
-        try:
-            self.__checkout(new_head.data.tree, iw)
-        except git.CheckoutException:
-            # We have to abort the transaction.
-            self.abort(iw)
-            self.__abort()
+        if iw:
+            try:
+                self.__checkout(new_head.data.tree, iw)
+            except git.CheckoutException:
+                # We have to abort the transaction.
+                self.abort(iw)
+                self.__abort()
         self.__stack.set_head(new_head, self.__msg)
 
         if self.__error: