Re: [PATCH v3 2/9] midx.c: make changing the preferred pack safe
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 14, 2022, 21:35 UTC
- Message-ID
- <xmqqwnj29f1v.fsf@gitster.g>
- In-Reply-To
- <7d20c13f8b48d2aef45c2c8c40efb6ecdb865aa8.1641320129.git.me@ttaylorr.com>
Taylor Blau <me@ttaylorr.com> writes:
> ... It's likely we were using > finalize_object_file() instead of a pure rename() because the former > also adjusts shared permissions.
I thought the primary reason why we use finalize was because we ignore EEXIST (and the assumption is that the files with the same contents get the same name computed from their contents).
Show 6 quoted lines
> tmp_file = write_rev_file_order(NULL, ctx->pack_order, ctx->entries_nr,
> midx_hash, WRITE_REV);
>
> - if (finalize_object_file(tmp_file, buf.buf))
> + if (rename(tmp_file, buf.buf))
> die(_("cannot store reverse index file"));Doesn't your new code die with it if buf.buf names an existing file?