Thread (6 messages) flat view 6 messages, 1 author, 2016-06-15
DORMANTno replies

[PATCH 4/5] Use a temporary index file when we merge the common ancestors.

From: Fredrik Kuivinen <hidden>
Date: 2016-06-15 22:42:06
Subsystem: the rest · Maintainer: Linus Torvalds

With this change we can get rid of a call to 'git-update-index
--refresh'.

Signed-off-by: Fredrik Kuivinen <redacted>


---

 git-merge-recursive.py |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

68a73c83a0ba2175cb366bddf3b851f824c6d598
diff --git a/git-merge-recursive.py b/git-merge-recursive.py
--- a/git-merge-recursive.py
+++ b/git-merge-recursive.py
@@ -10,6 +10,22 @@ from gitMergeCommon import *
 # The actual merge code
 # ---------------------
 
+originalIndexFile = os.environ.get('GIT_INDEX_FILE',
+                                   os.environ.get('GIT_DIR', '.git') + '/index')
+temporaryIndexFile = os.environ.get('GIT_DIR', '.git') + \
+                     '/merge-recursive-tmp-index'
+def setupIndex(temporary):
+    try:
+        os.unlink(temporaryIndexFile)
+    except OSError:
+        pass
+    if temporary:
+        newIndex = temporaryIndexFile
+        os.environ
+    else:
+        newIndex = originalIndexFile
+    os.environ['GIT_INDEX_FILE'] = newIndex
+
 def merge(h1, h2, branch1Name, branch2Name, graph, callDepth=0):
     '''Merge the commits h1 and h2, return the resulting virtual
     commit object and a flag indicating the cleaness of the merge.'''
@@ -39,13 +55,10 @@ def merge(h1, h2, branch1Name, branch2Na
         assert(isinstance(Ms, Commit))
 
     if callDepth == 0:
-        if len(ca) > 1:
-            runProgram(['git-read-tree', h1.tree()])
-            runProgram(['git-update-index', '-q', '--refresh'])
-        # Use the original index if we only have one common ancestor
-        
+        setupIndex(False)
         cleanCache = False
     else:
+        setupIndex(True)
         runProgram(['git-read-tree', h1.tree()])
         cleanCache = True
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help