From: Jeff King Date: Fri, 16 Oct 2026 03:14:39 GMT Subject: Re: [PATCH v2 2/2] odb: ignore refs of shallow and grafted alternates Message-ID: <20261016031439.GA3437448@coredump.intra.peff.net> 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