@matheusbsbs / matheus-bagliano / commits / 6511cce24b
Fork 0

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

With this change we can get rid of a call to 'git-update-index --refresh'. Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>

Fredrik Kuivinen committed Sep 13, 2005 at 23:41 UTC 6511cce24b932eba33d8e13b54664673121a8b7e
1 file changed +18 -5
git-merge-recursive.py
+18 -5
@@ -10,6 +10,22 @@ from gitMergeCommon import *
10 # The actual merge code
11 # ---------------------
12
13 +originalIndexFile = os.environ.get('GIT_INDEX_FILE',
14 + os.environ.get('GIT_DIR', '.git') + '/index')
15 +temporaryIndexFile = os.environ.get('GIT_DIR', '.git') + \
16 + '/merge-recursive-tmp-index'
17 +def setupIndex(temporary):
18 + try:
19 + os.unlink(temporaryIndexFile)
20 + except OSError:
21 + pass
22 + if temporary:
23 + newIndex = temporaryIndexFile
24 + os.environ
25 + else:
26 + newIndex = originalIndexFile
27 + os.environ['GIT_INDEX_FILE'] = newIndex
28 +
29 def merge(h1, h2, branch1Name, branch2Name, graph, callDepth=0):
30 '''Merge the commits h1 and h2, return the resulting virtual
31 commit object and a flag indicating the cleaness of the merge.'''
@@ -39,13 +55,10 @@ def merge(h1, h2, branch1Name, branch2Name, graph, callDepth=0):
55 assert(isinstance(Ms, Commit))
56
57 if callDepth == 0:
42 - if len(ca) > 1:
43 - runProgram(['git-read-tree', h1.tree()])
44 - runProgram(['git-update-index', '-q', '--refresh'])
45 - # Use the original index if we only have one common ancestor
46 -
58 + setupIndex(False)
59 cleanCache = False
60 else:
61 + setupIndex(True)
62 runProgram(['git-read-tree', h1.tree()])
63 cleanCache = True
64