Re: [PATCH] notes-merge: use O_EXCL to avoid overwriting existing files

2016-07-08 Thread Jeff King
On Thu, Jul 07, 2016 at 10:08:30PM +0200, René Scharfe wrote: > diff --git a/notes-merge.c b/notes-merge.c > index b7814c9..2b29fc4 100644 > --- a/notes-merge.c > +++ b/notes-merge.c > @@ -298,12 +298,8 @@ static void write_buf_to_worktree(const unsigned char > *obj, > char *path = git_path

Re: [PATCH] notes-merge: use O_EXCL to avoid overwriting existing files

2016-07-07 Thread Junio C Hamano
Jeff King writes: > Why do we care that the file exists? Should we instead be using the > lockfile code to get exclusive access to it? That would also switch us > to doing the write-to-tempfile-and-rename dance, but that seems like it > would be a good thing. If we hit a write() error in the code

Re: [PATCH] notes-merge: use O_EXCL to avoid overwriting existing files

2016-07-07 Thread Jeff King
On Thu, Jul 07, 2016 at 10:08:30PM +0200, René Scharfe wrote: > Use the open(2) flag O_EXCL to ensure the file doesn't already exist > instead of (racily) calling stat(2) through file_exists(). While at it > switch to xopen() to reduce code duplication and get more consistent > error messages. T

[PATCH] notes-merge: use O_EXCL to avoid overwriting existing files

2016-07-07 Thread René Scharfe
Use the open(2) flag O_EXCL to ensure the file doesn't already exist instead of (racily) calling stat(2) through file_exists(). While at it switch to xopen() to reduce code duplication and get more consistent error messages. Signed-off-by: Rene Scharfe --- notes-merge.c | 6 +- 1 file chang