git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Fredrik Kuivinen <freku045@student.liu.se>
Date
Sep 13, 2005, 21:41 UTC
Message-ID
<20050913214116.GE10953@c165.ib.student.liu.se>
In-Reply-To
<20050913213730.GA10953@c165.ib.student.liu.se>

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

Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
---
 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
 
Previous: Fredrik KuivinenNext: Fredrik Kuivinen
Message 5 of 6 in “More recursive merge updates”
  1. 0/5 More recursive merge updatesFredrik Kuivinen, Sep 13, 2005
  2. 1/5 Be more like the 'resolve' strategy.Fredrik Kuivinen, Sep 13, 2005
  3. 2/5 Don't output 'Automatic merge failed, ...'Fredrik Kuivinen, Sep 13, 2005
  4. 3/5 Adjust git-merge-recursive.py for the new tool names.Fredrik Kuivinen, Sep 13, 2005
  5. 4/5 Use a temporary index file when we merge the common ancestors.Fredrik Kuivinen, Sep 13, 2005
  6. 5/5 Use the 'die' function where it is appropriate.Fredrik Kuivinen, Sep 13, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.