Skip to content

Commit

Permalink
merge-recursive: cleanup setIndexStages
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Dec 11, 2005
1 parent 28e77a8 commit 157dc07
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions git-merge-recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,11 @@ def setIndexStages(path,
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
Expand Down Expand Up @@ -724,7 +718,6 @@ def processRenames(renamesA, renamesB, branchNameA, branchNameB):
cleanMerge = False

if not cacheOnly:
# Stuff stage1/2/3
setIndexStages(ren1.dstName,
oSHA1, oMode,
aSHA1, aMode,
Expand Down

0 comments on commit 157dc07

Please sign in to comment.