From: Karl Hasselström Date: Sun, 10 Feb 2008 14:43:41 +0000 (+0100) Subject: Don't check out files if we don't have index+workdir X-Git-Tag: v0.15-rc1~288 X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/commitdiff_plain/24d417c440e0209ebd058af586e5fbfe5341f2bf?hp=a639e7bbf3a6396254af76062ee88c22e4373340 Don't check out files if we don't have index+workdir 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 --- diff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py index 6a2ed81..3613b15 100644 --- a/stgit/lib/transaction.py +++ b/stgit/lib/transaction.py @@ -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: