From: Fredrik Kuivinen Date: Tue, 20 Sep 2005 05:50:22 GMT Subject: Re: Yet another set of merge test cases from the kernel tree. Message-ID: <20050920055022.GB12979@c165.ib.student.liu.se> In-Reply-To: <7vek7kfqs2.fsf@assigned-by-dhcp.cox.net> On Mon, Sep 19, 2005 at 06:53:49PM -0700, Junio C Hamano wrote: > Fredrik Kuivinen writes: > > > +def mergeFile(path, oSha, oMode, aSha, aMode, bSha, bMode, > > + branch1Name, branch2Name): > >... > > + if aMode == oMode: > > + mode = bMode > > + else: > > + mode = aMode > > Note: preferring "our" mode if there is a conflict instead of > barfing. I do not know which is more useful in practice. > I just realized that this piece of code is broken with respect to type changes. Trying to merge a symlink with a file should give us a conflict. > > + > > + return [sha, mode, clean, merge] > > + > > +def updateFile(clean, sha, mode, path, cleanCache, onlyWd=False): > > + updateCache = not onlyWd and (cleanCache or (not cleanCache and clean)) > > + updateWd = onlyWd or (not cleanCache and clean) > > + > > + if updateWd: > > + prog = ['git-cat-file', 'blob', sha] > > + if stat.S_ISREG(mode): > > + try: > > + os.unlink(path) > > + except OSError: > > + pass > > + if mode & 0100: > > + mode = 0777 > > + else: > > + mode = 0666 > > + fd = os.open(path, os.O_WRONLY | os.O_TRUNC | os.O_CREAT, mode) > > + proc = subprocess.Popen(prog, stdout=fd) > > + proc.wait() > > + os.close(fd) > > + elif stat.S_ISLNK(mode): > > + linkTarget = runProgram(prog) > > + os.symlink(linkTarget, path) > > + else: > > + assert(False) > > Could it happen trying to update a file 'foo' when the working > tree has 'foo/bar' file (i.e. D/F conflict)? > We get a list of all files and directories in getFilesAndDirs. This list is then used in processEntry to check for d/f conflicts, so it shouldn't happen in that case. The rename path do currently not check for d/f conflicts so it could probably happen there. - Fredrik