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

[PATCH 1/2] Add test for ls-tree with broken symlink under refs/heads

From
Petr Stodulka <pstodulk@redhat.com>
Date
Oct 14, 2016, 13:16 UTC
Message-ID
<1476451012-9925-2-git-send-email-pstodulk@redhat.com>
In-Reply-To
<1476451012-9925-1-git-send-email-pstodulk@redhat.com>
git ls-tree goes into an infinite loop while serving pretty vanilla requests,
if the refs/heads/ directory contains a symlink that's broken. Added test
which check if git ends with expected exit code or timeout expires.
---
 t/t3103-ls-tree-misc.sh | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/t/t3103-ls-tree-misc.sh b/t/t3103-ls-tree-misc.sh
index 09dcf04..faf79c4 100755
--- a/t/t3103-ls-tree-misc.sh
+++ b/t/t3103-ls-tree-misc.sh
@@ -21,4 +21,13 @@ test_expect_success 'ls-tree fails with non-zero exit code on broken tree' '
 	test_must_fail git ls-tree -r HEAD
 '
 
+test_expect_success 'ls-tree fails due to broken symlink instead of infinite loop' '
+	mkdir foo_infinit &&
+	cd foo_infinit &&
+	git init testrepo &&
+	cd testrepo &&
+	mkdir -p .git/refs/remotes &&
+	ln -s ../remotes/foo .git/refs/heads/bar &&
+	test_expect_code 128 timeout 2 git ls-tree bar
+'
 test_done
-- 
2.5.5
Previous: Petr StodulkaNext: Petr Stodulka
Message 2 of 6 in “infinite loop in "git ls-tree" for broken symlink”
  1. 0/2 infinite loop in "git ls-tree" for broken symlinkPetr Stodulka, Oct 14, 2016
  2. 1/2 Add test for ls-tree with broken symlink under refs/headsPetr Stodulka, Oct 14, 2016
  3. 2/2 resolve_ref_unsafe(): limit the number of "stat_ref" retriesPetr Stodulka, Oct 14, 2016
  4. Petr StodulkaOct 14, 2016
  5. Jeff KingOct 14, 2016
  6. Petr StodulkaOct 14, 2016

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.