From: Jeff King <peff@peff.net>
To: Igor Wiedler <iwiedler@gitlab.com>
Cc: git@vger.kernel.org, ps@pks.im, gitster@pobox.com, jltobler@gmail.com
Subject: Re: [PATCH v2 2/2] odb: ignore refs of shallow and grafted alternates
Date: Thu, 15 Oct 2026 23:14:39 -0400 [thread overview]
Message-ID: <20261016031439.GA3437448@coredump.intra.peff.net> (raw)
In-Reply-To: <20261014181134.56220-3-iwiedler@gitlab.com>
On Wed, Oct 14, 2026 at 08:11:34PM +0200, Igor Wiedler wrote:
> +test_expect_success 'refs of a shallow alternate are ignored' '
> + git clone --depth=1 "file://$TRASH_DIRECTORY" "$TRASH_DIRECTORY/shallow" &&
> + test_commit -C "$TRASH_DIRECTORY/shallow" shallow-only &&
> + git -C "$TRASH_DIRECTORY/shallow" rev-parse HEAD >shallow-tip &&
> + cp .git/objects/info/alternates alternates.bak &&
> + test_when_finished "mv alternates.bak .git/objects/info/alternates" &&
> + echo "$TRASH_DIRECTORY/shallow/.git/objects" >>.git/objects/info/alternates &&
> + git cat-file -e $(cat shallow-tip) &&
> + git rev-list --remotes=origin >expect &&
> + git rev-list --alternate-refs >actual &&
> + test_cmp expect actual
> +'
This seemed to fail the windows ci job with cat-file reporting:
error: unable to normalize alternate object path: /d/a/git/git/t/trash directory.t5618-alternate-refs/shallow/.git/objects
Just a guess, but it might be the Windows vs POSIX path thing? So
perhaps something like this would work, but I didn't test it:
diff --git a/t/t5618-alternate-refs.sh b/t/t5618-alternate-refs.sh
index 9c3862709a..e5dce85cff 100755
--- a/t/t5618-alternate-refs.sh
+++ b/t/t5618-alternate-refs.sh
@@ -76,7 +76,7 @@ test_expect_success 'refs of a shallow alternate are ignored' '
git -C "$TRASH_DIRECTORY/shallow" rev-parse HEAD >shallow-tip &&
cp .git/objects/info/alternates alternates.bak &&
test_when_finished "mv alternates.bak .git/objects/info/alternates" &&
- echo "$TRASH_DIRECTORY/shallow/.git/objects" >>.git/objects/info/alternates &&
+ echo "$(pwd)/shallow/.git/objects" >>.git/objects/info/alternates &&
git cat-file -e $(cat shallow-tip) &&
git rev-list --remotes=origin >expect &&
git rev-list --alternate-refs >actual &&
Alternatively, we could actually clone "shallow" with --reference or
--shared, which would let Git write the alternates file itself (but
would mean running rev-list, etc, in a subrepo).
We also mention $TRASH_DIRECTORY in some other spots. I think they are
not a problem, but usually we assume that tests start in the trash
directory and don't change directory (at least not outside of a
subshell). So as a matter of style, we can probably make all of those
relative paths.
Also, a very minor style nit, but we tend to use environment variables
instead of files for holding values. So all together, perhaps (again,
only lightly tested):
diff --git a/t/t5618-alternate-refs.sh b/t/t5618-alternate-refs.sh
index 9c3862709a..5ac981c5a0 100755
--- a/t/t5618-alternate-refs.sh
+++ b/t/t5618-alternate-refs.sh
@@ -71,13 +71,13 @@ test_expect_success 'connectivity check of a deepening fetch excludes alternate
'
test_expect_success 'refs of a shallow alternate are ignored' '
- git clone --depth=1 "file://$TRASH_DIRECTORY" "$TRASH_DIRECTORY/shallow" &&
- test_commit -C "$TRASH_DIRECTORY/shallow" shallow-only &&
- git -C "$TRASH_DIRECTORY/shallow" rev-parse HEAD >shallow-tip &&
+ git clone --depth=1 --no-local . shallow &&
+ test_commit -C shallow shallow-only &&
+ shallow_tip=$(git -C shallow rev-parse HEAD) &&
cp .git/objects/info/alternates alternates.bak &&
test_when_finished "mv alternates.bak .git/objects/info/alternates" &&
- echo "$TRASH_DIRECTORY/shallow/.git/objects" >>.git/objects/info/alternates &&
- git cat-file -e $(cat shallow-tip) &&
+ echo "$(pwd)/shallow/.git/objects" >>.git/objects/info/alternates &&
+ git cat-file -e $shallow_tip &&
git rev-list --remotes=origin >expect &&
git rev-list --alternate-refs >actual &&
test_cmp expect actual
-Peff
prev parent reply other threads:[~2026-10-16 3:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 10:35 [PATCH] connected: do not walk alternate refs in deepening fetches Igor Wiedler
2026-10-14 12:25 ` Patrick Steinhardt
2026-10-14 16:55 ` Junio C Hamano
2026-10-15 6:41 ` Jeff King
2026-10-14 17:02 ` Justin Tobler
2026-10-14 18:11 ` [PATCH v2 0/2] connected: fix the connectivity check with alternates " Igor Wiedler
2026-10-14 19:23 ` Junio C Hamano
2026-10-14 18:11 ` [PATCH v2 1/2] connected: negate alternate refs in deepening fetches too Igor Wiedler
2026-10-14 18:11 ` [PATCH v2 2/2] odb: ignore refs of shallow and grafted alternates Igor Wiedler
2026-10-15 6:57 ` Jeff King
2026-10-15 17:25 ` Junio C Hamano
2026-10-16 3:14 ` Jeff King [this message]
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=20261016031439.GA3437448@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=iwiedler@gitlab.com \
--cc=jltobler@gmail.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