{"thread":{"id":"19413","subject":"[PATCH] Transaction.push_patch(): Set self.head only when we have a merge conflict","startedAt":"2009-05-19T10:07:26Z","lastAt":"2009-05-19T10:07:26Z","messageCount":1,"participants":["Karl Hasselström"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"114251","messageId":"20090519100635.2943.31546.stgit@october.hq.vtech","threadId":"19413","inReplyTo":null,"subject":"[PATCH] Transaction.push_patch(): Set self.head only when we have a merge conflict","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-05-19T10:07:26Z","receivedAt":"2009-05-19T10:07:26Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Setting self.head when we don't have a merge conflict is a harmless\nno-op---as long as we set it to the commit that was going to be the\nstack top anyway---so this patch should not change the behavior. But\nit's not really nice to do it unconditionally, especially considering\nthat we want people to be able to understand what the code does ...\n\nAlso add a comment that explains why we set it, since the logic is\nrather more hairy than I'd like.\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\nThis patch came out of a discussion I just had with David regarding\nhis --set-tree patch.\n\n stgit/lib/transaction.py |    8 +++++++-\n 1 files changed, 7 insertions(+), 1 deletions(-)\n\n\ndiff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py\nindex 4148ff3..5c662bb 100644\n--- a/stgit/lib/transaction.py\n+++ b/stgit/lib/transaction.py\n@@ -342,7 +342,13 @@ class StackTransaction(object):\n         if any(getattr(cd, a) != getattr(orig_cd, a) for a in\n                ['parent', 'tree', 'author', 'message']):\n             comm = self.__stack.repository.commit(cd)\n-            self.head = comm\n+            if merge_conflict:\n+                # When we produce a conflict, we'll run the update()\n+                # function defined below _after_ having done the\n+                # checkout in run(). To make sure that we check out\n+                # the real stack top (as it will look after update()\n+                # has been run), set it hard here.\n+                self.head = comm\n         else:\n             comm = None\n             s = ' (unmodified)'\n"}]}