X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=git-merge-recursive.py;h=60e8b21b3b640868b027ba909a4221a5d1bdbf90;hb=28423758591577828672219c1031d463701a11cc;hp=145a5cf0d1fccc8ed6a18be4ae92af5e9cebe779;hpb=d9a23fa6f7124befe7803f5f3a8c53999578caa4;p=git.git diff --git a/git-merge-recursive.py b/git-merge-recursive.py index 145a5cf0..60e8b21b 100755 --- 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, branch2Name, graph, callDepth=0): assert(isinstance(Ms, Commit)) if callDepth == 0: - if len(ca) > 1: - runProgram(['git-read-tree', h1.tree()]) - runProgram(['git-update-cache', '-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 @@ -61,7 +74,7 @@ def merge(h1, h2, branch1Name, branch2Name, graph, callDepth=0): 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() @@ -86,7 +99,7 @@ class CacheEntry: 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 @@ -205,14 +218,14 @@ def processEntry(entry, branch1Name, branch2Name, files, dirs, cleanCache): assert(False) if updateWd and updateCache: - runProgram(['git-update-cache', '--add', '--', path]) + runProgram(['git-update-index', '--add', '--', path]) elif updateCache: - runProgram(['git-update-cache', '--add', '--cacheinfo', + runProgram(['git-update-index', '--add', '--cacheinfo', '0%o' % mode, sha, path]) def removeFile(clean, path): if cleanCache or (not cleanCache and clean): - runProgram(['git-update-cache', '--force-remove', '--', path]) + runProgram(['git-update-index', '--force-remove', '--', path]) if not cleanCache and clean: try: @@ -423,5 +436,4 @@ except: if clean: sys.exit(0) else: - print 'Automatic merge failed, fix up by hand' sys.exit(1)