From: Tyler Cipriani <tyler@tylercipriani.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Aleksei Sviridkin <f@lex.la>, git@vger.kernel.org
Subject: Re: [PATCH v2] push: fix --force-if-includes when remote-tracking ref has no reflog
Date: Fri, 25 Sep 2026 14:53:23 -0600 [thread overview]
Message-ID: <arbfQ7xF1NgDeilU@localhost.localdomain> (raw)
In-Reply-To: <xmqqv78dordu.fsf@gitster.g>
On 26-09-09 17:57:01, Junio C Hamano wrote:
<snip>
>Doesn't that mean it is more logical to use the default gc
>expiration timeout than year 1970 and in any cases using the usual
>gc expiration would not waste more time than using 1970, right?
I like date=0 (i.e., 1970).
Tested locally, in _most_ cases both give the right answer. But
date=<cutoff> can give the wrong answer in a subset of cases, and date=0
can give a slower answer in a subset of cases.
I think the wrong answer is worse, and I think the case where
date=<cutoff> provides a wrong answer is common for me (with default gc
settings and lots of old git clones).
The important bits of is_reachable_in_reflog:
- date: initial: either gc.reflogExpire (default: 90 days) or 0. Later:
maybe set by a walk of remote reflog.
- remote: e.g., remotes/origin/<x>
- local: e.g., refs/heads/<x>
- remote->old_oid: advertised oid for remote ref
We need to find remote->old_oid in the local reflog. We can't build on a
commit we've never fetched, so we set date to the last time remote's
reflog moved to bound our walk of local.
But remote's reflog can expire or be empty, so it needs an initial
value.
With date=0 (and remote gone: older than 90 days + gc, removed, or fresh
clone), we walk local until we find the remote->old_oid or we run out of
reflog to walk. But local is also subject to gc, so by default that's 90
days without having to bound anything. Since both reflogs are gc'd, the
time difference should be minimal.
With date=<cutoff> is only faster where we have no remote reflog, we
don't have remote->old_oid in our local, and our local reflog has
entries older than the typical gc cutoff; viz. I'm rebuilding history
without the remote tip and: (a) expired my remote reflog manually (b)
have my remote reflog gc configured differently than my local or (c) I
have gc turned off.
But in one case, date=0 gives the right answer and the cutoff date gives
the wrong answer:
git clone ... # 1. files backend, no remote reflog
git reset --hard HEAD^ # 2. start a rewrite
... # 3. do nothing for gc.reflogExpire amount
... # of time.
... # Remote never moves/we never fetch.
git commit ... # 4. Finish rewrite and push
git push --force-if-includes --force-with-lease origin main
Push fails with date=gc.reflogExpire (wrong). Push succeeds with date=0
(right).
And nothing about gc config need be tweaked from the defaults for this
to happen---git gc can even happen (provided it runs between the initial
clone and the reset, since the reflogUnreachable prune is 30 days by
default). But in small repos, gc may not have been triggered at all.
So date=0 is always correct and should have equivalent in runtime in
most cases. And it neatly side-steps what cut off should we use?
gc.reflogExpire vs. gc.<remote>.reflogExpire vs.
gc.<local>.reflogExpire vs. flat 90 days vs. do we respect
gc.reflogExpire=never.
Thanks.
next prev parent reply other threads:[~2026-09-25 20:53 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 1:05 [PATCH] push: fix --force-if-includes when remote-tracking ref has no reflog Aleksei Sviridkin
2026-09-03 16:16 ` Junio C Hamano
2026-09-03 20:00 ` Aleksei Sviridkin
2026-09-03 20:11 ` Junio C Hamano
2026-09-03 21:45 ` Aleksei Sviridkin
2026-09-04 1:03 ` Kristoffer Haugsbakk
2026-09-04 16:48 ` Junio C Hamano
2026-09-05 17:13 ` Aleksei Sviridkin
2026-09-06 9:39 ` Kristoffer Haugsbakk
2026-09-06 17:14 ` Junio C Hamano
2026-09-07 4:54 ` Thomas Bachem
2026-09-07 6:23 ` Weijie Yuan
2026-09-04 12:44 ` [PATCH v2] " Aleksei Sviridkin
2026-09-04 15:42 ` Junio C Hamano
2026-09-06 0:45 ` Junio C Hamano
2026-09-06 16:50 ` Aleksei Sviridkin
2026-09-08 3:47 ` Junio C Hamano
2026-09-09 6:56 ` Aleksei Sviridkin
2026-09-10 0:57 ` Junio C Hamano
2026-09-10 8:31 ` Aleksei Sviridkin
2026-09-25 20:53 ` Tyler Cipriani [this message]
2026-09-25 21:58 ` Junio C Hamano
2026-09-05 17:13 ` [PATCH v3] " Aleksei Sviridkin
2026-09-29 1:10 ` Tyler Cipriani
2026-09-29 18:05 ` Junio C Hamano
2026-09-29 9:13 ` [PATCH v4] " Aleksei Sviridkin
2026-09-29 16:54 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=arbfQ7xF1NgDeilU@localhost.localdomain \
--to=tyler@tylercipriani.com \
--cc=f@lex.la \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.