chiark / gitweb /
'stg pop --keep' doesn't update the index
authorCatalin Marinas <catalin.marinas@gmail.com>
Wed, 14 Nov 2007 21:14:55 +0000 (21:14 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Wed, 14 Nov 2007 21:14:55 +0000 (21:14 +0000)
While git.apply_diff works correctly, the git.switch implementation
doesn't update the index (only the HEAD) and a subsequent 'stg refresh'
would merge all the popped patches into the current one ('stg refresh
--patch' fails in the same way). This patch fixes git.switch to read the
new index (git-read-tree) if keep == True.

Before commit a77bfa77 (to fix bug #8972), git-apply had the --index
option to automatically update the index but it was failing in many
cases.

The drawback is that a subsequent git-update-index takes longer than
usual, but at least we have a correct behaviour.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/git.py

index 7e1df1eadbcff7b4631260db74f5b4b402999209..d0eef84355cbc32a336bb67934a8ea9b1c0f5280 100644 (file)
@@ -820,7 +820,10 @@ def checkout(files = None, tree_id = None, force = False):
 def switch(tree_id, keep = False):
     """Switch the tree to the given id
     """
-    if not keep:
+    if keep:
+        # only update the index while keeping the local changes
+        GRun('git-read-tree', tree_id).run()
+    else:
         refresh_index()
         try:
             GRun('git-read-tree', '-u', '-m', get_head(), tree_id).run()