From c7427d68c3b66db858f87d033b047732d1cf068b Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 15:26:04 -1000 Subject: Check the commit-graph hook with a git too old The header says a git too old for the options leaves the graph as it was and the hook stays silent, but every run had a git that could write it. --- tests/t0507-hooks.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests') diff --git a/tests/t0507-hooks.sh b/tests/t0507-hooks.sh index b695e03..0a869f9 100755 --- a/tests/t0507-hooks.sh +++ b/tests/t0507-hooks.sh @@ -417,6 +417,30 @@ do test_grep ! "^$newest\$" chain-$shell && git -C graph-$shell.git commit-graph verify ' + + test_expect_success "a git too old to write the graph leaves it quietly under $shell" ' + mkdir -p old-git && + write_script old-git/git <<-\EOF && + if test "$1" = commit-graph + then + echo "error: unknown option" >&2 + exit 129 + fi + exec "$REAL_GIT" "$@" + EOF + real_git=$(command -v git) && + shim="$PWD/old-git" && + graphs=graph-$shell.git/objects/info/commit-graphs && + cp $graphs/commit-graph-chain old-chain-$shell && + test_commit -C work old-$shell && + git -C work push -q ../graph-$shell.git HEAD:main && + ( + cd graph-$shell.git && + REAL_GIT=$real_git PATH="$shim:$PATH" $run "$HOOK_DIRECTORY/post-receive.commit-graph" 2>../err + ) && + test_must_be_empty err && + test_cmp old-chain-$shell $graphs/commit-graph-chain + ' done test_done -- cgit 2.12.1