# Re: \[PATCH\] notes-merge: use O\_EXCL to avoid overwriting existing files

- From: Junio C Hamano \<hidden\>
- Date: 2016-07-07 21:10:23 
- List: git
- Page: https://ratatoskr.run/git/2016/07/7685183
- Thread: https://ratatoskr.run/git/2016/07/7685183/t.md

```text
Jeff King [ref] 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 now, we
> leave a partially-written file in the notes worktree.

Yeah, I had the same thought when I saw the change.

> I dunno. From my cursory reading of the code, it seems like we'd never
> really expect this file_exists() to trigger in the first place, so
> perhaps it's not worth thinking too hard about it.

Perhaps.
```
