From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Heghedus Razvan <heghedus.razvan@protonmail.com>
Subject: Re: [PATCH] setup: fix bug with "includeIf.onbranch" when initializing dir
Date: Wed, 22 May 2024 17:41:28 -0700 [thread overview]
Message-ID: <xmqq4jap1hs7.fsf@gitster.g> (raw)
In-Reply-To: <cf182bb9ee7d4a7eb46e5dbf4f3ef5deb198d823.1716374321.git.ps@pks.im> (Patrick Steinhardt's message of "Wed, 22 May 2024 12:38:46 +0200")
Patrick Steinhardt <ps@pks.im> writes:
> The bug has been introduced in 173761e21b (setup: start tracking ref
> storage format, 2023-12-29), which wired up the ref storage format. The
> root cause is in `init_db()`, which tries to read the config before we
> have initialized `the_repository` and most importantly its ref storage
> format. We eventually end up calling `include_by_branch()` and execute
> `refs_resolve_ref_unsafe()`, but because we have not initialized the ref
> storage format yet this will trigger the above bug.
So I was trying to see how feasible it would be to backport this fix
on top of v2.44.0 which was the first version that was shipped with
173761e2 (setup: start tracking ref storage format, 2023-12-29),
which is v2.44.0-rc0~78^2~8 and noticed something curious.
As your addition to t0001-init.sh wants to try converting the ref
backends to and from files and reftable, it actually will barf until
b4385bf0 (Merge branch 'ps/reftable-backend', 2024-02-26), which is
v2.45.0-rc0~176, but even with a reinit with the same backend, the
problem should manifest itself, right?
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index b131d665db..2239bed198 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -584,14 +584,38 @@ test_expect_success 'init with --ref-format=files' '
> test_cmp expect actual
> '
>
> -test_expect_success 're-init with same format' '
> - test_when_finished "rm -rf refformat" &&
> - git init --ref-format=files refformat &&
> - git init --ref-format=files refformat &&
> - echo files >expect &&
> - git -C refformat rev-parse --show-ref-format >actual &&
> - test_cmp expect actual
> -'
So we used to have "files to files" and nothing else. But
> +for from_format in files reftable
> +do
> + for to_format in files reftable
> + do
> + if test "$from_format" = "$to_format"
> + then
> + continue
> + fi
> +
> + test_expect_success "re-init with same format ($from_format)" '
> + test_when_finished "rm -rf refformat" &&
> + git init --ref-format=$from_format refformat &&
> + git init --ref-format=$from_format refformat &&
> + echo $from_format >expect &&
> + git -C refformat rev-parse --show-ref-format >actual &&
> + test_cmp expect actual
> + '
This is very iffy, isn't it? This one wants to do the same format
reinit, but it is behind "if from and to are the same, skip the rest"
in the loop.
I think the "same format" loop should be lifted outside and
immediately before the inner loop and we should be OK.
> + test_expect_success "re-init with different format fails ($from_format -> $to_format)" '
> + test_when_finished "rm -rf refformat" &&
> + git init --ref-format=$from_format refformat &&
> + cat >expect <<-EOF &&
> + fatal: attempt to reinitialize repository with different reference storage format
> + EOF
> + test_must_fail git init --ref-format=$to_format refformat 2>err &&
> + test_cmp expect err &&
> + echo $from_format >expect &&
> + git -C refformat rev-parse --show-ref-format >actual &&
> + test_cmp expect actual
> + '
> + done
> +done
In any case, this "reinitialize to a different format is too late"
test has nothing to do with the problem we are fixing with this
patch, no? It is a valuable set of tests in the post b4385bf0 world
where we can choose between the two, but it is somewhat out of scope
of the "we need to initialize the ref backend before we can do onbranch
config".
I'll send your patch backported to v2.44.0, plus the change needed
to review the merge of it into v2.45.0 codebase later.
next prev parent reply other threads:[~2024-05-23 0:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-21 7:54 git init BUG when gitconfig has includeIf Heghedus Razvan
2024-05-21 16:36 ` Junio C Hamano
2024-05-21 16:46 ` Heghedus Razvan
2024-05-22 8:06 ` Patrick Steinhardt
2024-05-22 8:21 ` Heghedus Razvan
2024-05-22 8:27 ` Patrick Steinhardt
2024-05-22 10:38 ` [PATCH] setup: fix bug with "includeIf.onbranch" when initializing dir Patrick Steinhardt
2024-05-22 10:58 ` Heghedus Razvan
2024-05-22 19:06 ` Junio C Hamano
2024-05-23 0:41 ` Junio C Hamano [this message]
2024-05-23 5:26 ` Patrick Steinhardt
2024-05-23 0:43 ` [PATCH v2] " Junio C Hamano
2024-05-23 0:56 ` [rPATCH " Junio C Hamano
2024-05-23 5:26 ` [PATCH " Patrick Steinhardt
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=xmqq4jap1hs7.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=heghedus.razvan@protonmail.com \
--cc=ps@pks.im \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).