Re: [PATCH 22/22] lockfile: allow new file contents to be written while retaining lock
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 2, 2014, 17:26 UTC
- Message-ID
- <xmqq38hvwskl.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <1396367910-7299-23-git-send-email-mhagger@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 8 quoted lines
> +static int open_staging_file(struct lock_file *lk)
> +{
> + strbuf_setlen(&lk->staging_filename, lk->filename.len);
> + strbuf_addstr(&lk->staging_filename, ".new");
> + lk->fd = open(lk->staging_filename.buf, O_RDWR | O_CREAT | O_EXCL, 0666);
> + if (lk->fd < 0) {
> + return -1;
> + }All the other "if (lk->fd < 0)" calls reset_lock_file(lk). Is it an intentional omission that this one does not?
If so, please drop the extraneous {} around the single "return -1" statement.
I also share the same puzzlement in Peff's review.