Anonymous avatar Anonymous committed 157dc07

merge-recursive: cleanup setIndexStages

Fredrik points out there is a useful wrapper runProgram() used
everywhere that we can use to feed input into subprocess. Use
it to catch errors from the subprocess; it is a good cleanup as
well.

Signed-off-by: Junio C Hamano <junkio@cox.net>;

Comments (0)

Files changed (1)

git-merge-recursive.py

                    oSHA1, oMode,
                    aSHA1, aMode,
                    bSHA1, bMode):
-    prog = ['git-update-index', '-z', '--index-info']
-    proc = subprocess.Popen(prog, stdin=subprocess.PIPE)
-    pipe = proc.stdin
-    # Clear stages first.
-    pipe.write("0 " + ("0" * 40) + "\t" + path + "\0")
-    # Set stages
-    pipe.write("%o %s %d\t%s\0" % (oMode, oSHA1, 1, path))
-    pipe.write("%o %s %d\t%s\0" % (aMode, aSHA1, 2, path))
-    pipe.write("%o %s %d\t%s\0" % (bMode, bSHA1, 3, path))
-    pipe.close()
-    proc.wait()
+    runProgram(['git-update-index', '-z', '--index-info'],
+               input="0 " + ("0" * 40) + "\t" + path + "\0" + \
+               "%o %s %d\t%s\0" % (oMode, oSHA1, 1, path) + \
+               "%o %s %d\t%s\0" % (aMode, aSHA1, 2, path) + \
+               "%o %s %d\t%s\0" % (bMode, bSHA1, 3, path))
 
 def removeFile(clean, path):
     updateCache = cacheOnly or clean
                     cleanMerge = False
 
                     if not cacheOnly:
-                        # Stuff stage1/2/3
                         setIndexStages(ren1.dstName,
                                        oSHA1, oMode,
                                        aSHA1, aMode,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.