Re: [PATCH v5 2/2] merge-ort: return early when failing to write a blob
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 28, 2022, 15:53 UTC
- Message-ID
- <xmqqleq3zea3.fsf@gitster.g>
- In-Reply-To
- <bfc71a2d8adfbf9b899a47d469fe2343e4703ff7.1664350162.git.gitgitgadget@gmail.com>
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 21 quoted lines
> This is _not_ just a cosmetic change: Even though one might assume that > the operation would have failed anyway at the point when the new tree > object is written (and the corresponding tree object _will_ be new if it > contains a blob that is new), but that is not so: As pointed out by > Elijah Newren, when Git has previously been allowed to add loose objects > via `sudo` calls, it is very possible that the blob object cannot be > written (because the corresponding `.git/objects/??/` directory may be > owned by `root`) but the tree object can be written (because the > corresponding objects directory is owned by the current user). This > would result in a corrupt repository because it is missing the blob > object, and with this here patch we prevent that. > > Note: This patch adjusts two variable declarations from `unsigned` to > `int` because their purpose is to hold the return value of > `handle_content_merge()`, which is of type `int`. The existing users of > those variables are only interested whether that variable is zero or > non-zero, therefore this type change does not affect the existing code. > > Reviewed-by: Elijah Newren <newren@gmail.com> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > ---
Thanks. The first paragraph in the quoted part above is new and not exactly "reviewed" by Elijah yet, so let's ask ;-)
To me the description of the issue looks reasonable to me. Any comments, Elijah?
The code is the same as the one in the previous round and Elijah gave his Reviewed-by, and does look good to me, too.
> merge-ort.c | 28 +++++++++++++++++++--------- > 1 file changed, 19 insertions(+), 9 deletions(-)
Thanks, all. Queued.