# 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.'''
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
return [res, clean]
-getFilesRE = re.compile('([0-9]+) ([a-z0-9]+) ([0-9a-f]{40})\t(.*)')
+getFilesRE = re.compile(r'^([0-7]+) (\S+) ([0-9a-f]{40})\t(.*)$', re.S)
def getFilesAndDirs(tree):
files = Set()
dirs = Set()
self.stages = [Stage(), Stage(), Stage()]
self.path = path
-unmergedRE = re.compile('^([0-9]+) ([0-9a-f]{40}) ([1-3])\t(.*)$')
+unmergedRE = re.compile(r'^([0-7]+) ([0-9a-f]{40}) ([1-3])\t(.*)$', re.S)
def unmergedCacheEntries():
'''Create a dictionary mapping file names to CacheEntry
objects. The dictionary contains one entry for every path with a