Re: [PATCH] push: make `--force-with-lease[=<ref>]` safer
- From
Srinidhi Kaushik <shrinidhi.kaushik@gmail.com>
- Date
- Sep 14, 2020, 11:06 UTC
- Message-ID
- <20200914110638.GA32876@mail.clickyotomy.dev>
- In-Reply-To
- <nycvar.QRO.7.76.6.2009120013070.56@tvgsbejvaqbjf.bet>
Hi Johannes,
On 09/12/2020 00:16, Johannes Schindelin wrote:
Show 15 quoted lines
> > + static int oid_in_reflog_ent(struct object_id *ooid, struct object_id *noid,
> > + const char *ident, timestamp_t timestamp, int tz,
> > + const char *message, void *cb_data)
> > + {
> > + struct object_id *remote_oid = cb_data;
> > + struct commit *a = lookup_commit_reference(the_repository, noid);
> > + struct commit *b = lookup_commit_reference(the_repository, remote_oid);
> > + return oideq(noid, remote_oid) || in_merge_bases(b, a);
> > + }
>
> Since `in_merge_bases()` is quite a bit more expensive than `oideq()`,
> personally, I would actually walk the reflog with the `oideq()` check
> first (stopping early in case a match was found), and only fall back to
> looking for a merge base in the reflog if the first reflog walk did not
> find a match.Thanks for the suggestion; the updated the patch set (v3) - [1] does something similar to that, along with some other changes. Can you please take a look?
[1]: https://public-inbox.org/git/20200913145413.18351-2-shrinidhi.kaushik@gmail.com/
Thanks.
-- Srinidhi Kaushik