git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/2] odb: ignore refs of shallow and grafted alternates

From
Jeff King <peff@peff.net>
Date
Oct 16, 2026, 03:14 UTC
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:
Show 12 quoted lines
> +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
Previous: Junio C HamanoNext: Igor Wiedler
Message 19 of 21 in “connected: do not walk alternate refs in deepening fetches”
  1. connected: do not walk alternate refs in deepening fetchesIgor Wiedler, Oct 14, 2026
  2. Patrick SteinhardtOct 14, 2026
  3. Junio C HamanoOct 14, 2026
  4. Jeff KingOct 15, 2026
  5. Justin ToblerOct 14, 2026
  6. 0/2 connected: fix the connectivity check with alternates in deepening fetchesIgor Wiedler, Oct 14, 2026
  7. Junio C HamanoOct 14, 2026
  8. 0/2 connected: fix the connectivity check with alternates in deepening fetchesIgor Wiedler, Oct 19, 2026
  9. Junio C HamanoOct 19, 2026
  10. Igor WiedlerOct 20, 2026
  11. Patrick SteinhardtOct 23, 2026
  12. 1/2 connected: negate alternate refs in deepening fetches tooIgor Wiedler, Oct 19, 2026
  13. 2/2 odb: ignore refs of shallow and grafted alternatesIgor Wiedler, Oct 19, 2026
  14. Patrick SteinhardtOct 23, 2026
  15. 1/2 connected: negate alternate refs in deepening fetches tooIgor Wiedler, Oct 14, 2026
  16. 2/2 odb: ignore refs of shallow and grafted alternatesIgor Wiedler, Oct 14, 2026
  17. Jeff KingOct 15, 2026
  18. Junio C HamanoOct 15, 2026
  19. Jeff KingOct 16, 2026
  20. Igor WiedlerOct 19, 2026
  21. Junio C HamanoOct 18, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.