From: Elijah Newren Date: Thu, 29 Sep 2022 01:36:33 GMT Subject: Re: [PATCH v5 2/2] merge-ort: return early when failing to write a blob Message-ID: In-Reply-To: On Wed, Sep 28, 2022 at 8:53 AM Junio C Hamano wrote: > > "Johannes Schindelin via GitGitGadget" > writes: > > > 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 > > Signed-off-by: Johannes Schindelin > > --- > > 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? Looks good to me!