Re: [RFC PATCH] merge-recursive: create new files with O_EXCL
flat view
From: Elijah Newren <hidden>
Date: 2021-03-11 18:03:00
On Thu, Mar 11, 2021 at 1:58 AM Ephrim Khong [off-list ref] wrote:
On 11.03.2021 00:01, Junio C Hamano wrote:quoted
Ephrim Khong [off-list ref] writes:
As a side-note, the strace on the affected file also shows that git writes that file twice during the merge, with the same content. There might be some potential to further optimize merges to avoid such double-writes. A small example to reproduce, note how "b" is opened twice during the merge: git init echo "foo" > a git add a git commit -m "Initial commit" git mv a b git commit -m "File moved" git checkout -b other_branch HEAD~ touch c && git add c && git commit -m "Some other commit" strace -otrace git merge master -m "merge message" grep '"b"' trace
Yeah, this is somewhat fundamental to merge-recursive's implementation design; fixing it essentially requires a rewrite. That rewrite is nearing completion; so this double-write issue will be fixed when merge-ort is complete (or for anyone who applies the patches and tries it out now). In fact, if you don't see the permissions problems when switching branches (because branch switching uses O_EXCL?), then merge-ort almost certainly incidentally fixes that problem for you as well.