Changes since v3: * Move run_with_limited_processses() into t5330-no-lazy-fetch-with-commit-graph.sh without touching test-lib.sh. * Squash "setup: prepare any commit to fetch" into the main body of the test. * Minor grammar/comment etc. fixes throughout. Han Xin (1): commit-graph.c: no lazy fetch in lookup_commit_in_graph() commit-graph.c | 2 +- t/t5330-no-lazy-fetch-with-commit-graph.sh | 70 ++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100755 t/t5330-no-lazy-fetch-with-commit-graph.sh Range-diff against v3: 1: ad0a539759 < -: ---------- test-lib.sh: add limited processes to test-lib 2: 3cdb1abd43 ! 1: 96d4bb7150 commit-graph.c: no lazy fetch in lookup_commit_in_graph() @@ commit-graph.c: struct commit *lookup_commit_in_graph(struct repository *repo, c commit = lookup_commit(repo, id); - ## t/t5329-no-lazy-fetch-with-commit-graph.sh (new) ## + ## t/t5330-no-lazy-fetch-with-commit-graph.sh (new) ## @@ +#!/bin/sh + @@ t/t5329-no-lazy-fetch-with-commit-graph.sh (new) + +. ./test-lib.sh + ++run_with_limited_processses () { ++ # bash and ksh use "ulimit -u", dash uses "ulimit -p" ++ if test -n "$BASH_VERSION" ++ then ++ ulimit_max_process="-u" ++ elif test -n "$KSH_VERSION" ++ then ++ ulimit_max_process="-u" ++ fi ++ (ulimit ${ulimit_max_process-"-p"} 512 && "$@") ++} ++ ++test_lazy_prereq ULIMIT_PROCESSES ' ++ run_with_limited_processses true ++' ++ +if ! test_have_prereq ULIMIT_PROCESSES +then + skip_all='skipping tests for no lazy fetch with the commit-graph, ulimit processes not available' @@ t/t5329-no-lazy-fetch-with-commit-graph.sh (new) + +test_expect_success 'setup: change the alternates to what without the commit' ' + git init --bare without-commit && ++ git -C with-commit-graph cat-file -e $oid && + echo "$(pwd)/without-commit/objects" \ + >with-commit-graph/.git/objects/info/alternates && + test_must_fail git -C with-commit-graph cat-file -e $oid +' + -+test_expect_success 'setup: prepare any commit to fetch' ' -+ test_commit -C with-commit any-commit && -+ anycommit=$(git -C with-commit rev-parse HEAD) -+' -+ +test_expect_success 'fetch any commit from promisor with the usage of the commit graph' ' ++ # setup promisor and prepare any commit to fetch + git -C with-commit-graph remote add origin "$(pwd)/with-commit" && + git -C with-commit-graph config remote.origin.promisor true && + git -C with-commit-graph config remote.origin.partialclonefilter blob:none && -+ run_with_limited_processses env GIT_TRACE="$(pwd)/trace" \ ++ test_commit -C with-commit any-commit && ++ anycommit=$(git -C with-commit rev-parse HEAD) && ++ ++ run_with_limited_processses env GIT_TRACE="$(pwd)/trace.txt" \ + git -C with-commit-graph fetch origin $anycommit 2>err && -+ test_i18ngrep ! "fatal: promisor-remote: unable to fork off fetch subprocess" err && -+ test $(grep "fetch origin" trace | wc -l) -eq 1 ++ ! grep "fatal: promisor-remote: unable to fork off fetch subprocess" err && ++ grep "git fetch origin" trace.txt >actual && ++ test_line_count = 1 actual +' + +test_done -- 2.36.1