Thread View: linux.kernel.git
1 messages
1 total messages
Started by Karthik Nayak
Wed, 18 Nov 2026 11:33
Re: [PATCH 2/4] refs/reftable: don't write new table when expire is a no-op
Author: Karthik Nayak
Date: Wed, 18 Nov 2026 11:33
Date: Wed, 18 Nov 2026 11:33
117 lines
16188 bytes
16188 bytes
--00000000000004f00906608b60ad
Content-Type: text/plain; charset="UTF-8"
Patrick Steinhardt <ps@pks.im> writes:
> diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
> index 4216a18684d..e2027bb9c02 100644
> --- a/refs/reftable-backend.c
> +++ b/refs/reftable-backend.c
> @@ -2607,6 +2607,7 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
> struct strbuf referent = STRBUF_INIT;
> uint8_t *last_hash = NULL;
> size_t logs_nr = 0, logs_alloc = 0, i;
> + bool has_changes = false;
> unsigned int type = 0;
> int ret;
>
> @@ -2696,17 +2697,25 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
> logs[i].value.update.message,
> policy_cb_data)) {
> dest->value_type = REFTABLE_LOG_DELETION;
> + has_changes = true;
> } else {
> - if ((flags & EXPIRE_REFLOGS_REWRITE) && last_hash)
> + if ((flags & EXPIRE_REFLOGS_REWRITE) && last_hash &&
> + memcmp(dest->value.update.old_hash, last_hash,
> + ref_store->repo->hash_algo->rawsz)) {
> memcpy(dest->value.update.old_hash, last_hash, GIT_MAX_RAWSZ);
We can skip this second copy.
> + has_changes = true;
> + }
> last_hash = logs[i].value.update.new_hash;
> }
> }
>
> - if (flags & EXPIRE_REFLOGS_UPDATE_REF && last_hash && !is_null_oid(&oid))
> + if (flags & EXPIRE_REFLOGS_UPDATE_REF && last_hash && !is_null_oid(&oid)) {
> oidread(&arg.update_oid, last_hash, ref_store->repo->hash_algo);
> + if (!oideq(&arg.update_oid, &oid))
We now check if its changed, makes sense.
> + has_changes = true;
> + }
>
> - if ((flags & EXPIRE_REFLOGS_DRY_RUN)) {
> + if (!has_changes || (flags & EXPIRE_REFLOGS_DRY_RUN)) {
> ret = 0;
> goto done;
> }
Nit: it would be nice to mention that we exit early to skip writing any
new tables.
> diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh
> index a7027458395..d808f1887f6 100755
> --- a/t/t0610-reftable-basics.sh
> +++ b/t/t0610-reftable-basics.sh
> @@ -912,6 +912,36 @@ test_expect_success 'reflog: expiry empties reflog' '
> )
> '
>
> +test_expect_success 'reflog: expiry without changes does not write tables' '
> + test_when_finished "rm -rf repo" &&
> + git init repo &&
> + (
> + cd repo &&
> +
> + test_commit A &&
> + test_commit B &&
> + test_commit C &&
> + cp .git/reftable/tables.list expect &&
> +
> + git reflog expire --all --expire=never --expire-unreachable=never &&
> + test_cmp expect .git/reftable/tables.list &&
> +
> + git reflog expire --all --rewrite \
> + --expire=never --expire-unreachable=never &&
> + test_cmp expect .git/reftable/tables.list &&
> +
> + git reflog expire --all --updateref \
> + --expire=never --expire-unreachable=never &&
> + test_cmp expect .git/reftable/tables.list &&
> +
> + git reflog expire --all --dry-run --expire=all &&
> + test_cmp expect .git/reftable/tables.list &&
> +
> + git reflog expire --all --expire=all &&
> + ! test_cmp expect .git/reftable/tables.list
> + )
> +'
Nice. Could we add a similar test for the previous patch too?
--00000000000004f00906608b60ad
Content-Type: application/pgp-signature; name="signature.asc"
Content-Disposition: attachment; filename="signature.asc"
Content-Transfer-Encoding: base64
X-Attachment-Id: 73f2657ec1ecfba9_0.1
LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSEtCQUVCQ2dBMEZpRUVWODVNZjJOMWNR
L0xaY1lHUHRXZkpJNUdqSDhGQW1yOWpPMFdIR3RoY25Sb2FXc3UKTVRnNFFHZHRZV2xzTG1OdmJR
QUtDUkErMVo4a2prYU1mM2VCQy93TGdrdDY2Y0FTRit5L2MrOVljOHVFazRhVwovdUVpWkhQL3M5
ckVrWit2YzBuTzJCdmduMmFsVmcwQ1JRMnF0TlZHYWwwdnhQeUpDaEtNT05DSzBmYnI4U21VClV6
aitBbjJHeDl0ME8ybXVSSi9jYXZ6VUtKTzd2Y3BLQjNaRjhHSU44TlVjZTdQajRWQ0x6SCtHZkJV
Y2t2dVYKbmZvNmk1d3Boc3hMU2xlU3MrU1lCcStMZEo1MlBJbDFFaW0vcmFaaHlXVnlJejRQbTdq
VGZCallPejkyOXZMcwpQTG5IeFBuV1RSdnhzOHNySmZBN2Z6Wnd0WlpsSUdSQUwvNnpLTndXR0V6
QzNGL1pJZUR2SG5KYi9mREVTNFd1CjJUcGs1em9va3ExK2djL2R6WWFrSktOWVBZdHN4eUpLK2Yw
YlAvalJXd3N6ejFadWptUXluVTZadUVRZjNJYUUKUDVMTDFyNUZpQ285Q0pCTllWMWQzQUp1MHVH
cmd6azNKQ3JOaGtGbGJMUGZwOHFJVU1HYkJreDNaL2YyYlZhbAo5M3pmbFZZNFo2QUJtVjQ5Rmhr
alNzL2V1T0oyTWhRMmQvKzlZYW5KZ3ZUT3pXVFdDSldUWmo1dXk3OVlnVWt4CkJPQ0N5NU1naFhB
elVUVTF2Qi9GdzRUUDFtRkoyVTUvOXlZaVBRMD0KPWtiUkIKLS0tLS1FTkQgUEdQIFNJR05BVFVS
RS0tLS0t
--00000000000004f00906608b60ad--
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads