Re: [PATCH v2] push: fix --force-if-includes when remote-tracking ref has no reflog
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 6, 2026, 00:45 UTC
- Message-ID
- <xmqq33vn5hsq.fsf@gitster.g>
- In-Reply-To
- <xmqqzexx58hc.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
> Aleksei Sviridkin <f@lex.la> writes:
>
>> static int is_reachable_in_reflog(const char *local, const struct ref *remote)
>> {
>> - timestamp_t date;
>> + timestamp_t date = 0;
>> struct commit *commit;
>> struct commit **chunk;
>> struct check_and_collect_until_cb_data cb;
>
> This gives a known value to the "date" variable, solving the issue
> of using an uninitialized variable. But how do we know if "0" a
> reasonable fall-back value? Why is it better than "now" or perhaps
> "2 weeks ago"?Thinking about it a bit more, let's imagine that we had reflog enabled and did not have to suffer from this "uninitialized variable" problem. Even if the reflog for the remote-tracking branch were enabled long ago and had plenty of entries, it wouldn't have any entry older than 90 days, or the value gc.reflogExpire is set. Which suggests to me that gc.reflogExpire or 90 days ago would be a lot more reasonable than year 1970 to use as a fallback cutoff date.
Thanks.