This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
gitgram-ai/aitimemachine/git/t/t4072-diff-max-depth.sh
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

117 lines
3.3 KiB
Bash
Executable File

#!/bin/sh
test_description='check that diff --max-depth will limit recursion'
. ./test-lib.sh
make_dir() {
mkdir -p "$1" &&
echo "$2" >"$1/file"
}
make_files() {
echo "$1" >file &&
make_dir one "$1" &&
make_dir one/two "$1" &&
make_dir one/two/three "$1"
}
test_expect_success 'setup' '
git commit --allow-empty -m empty &&
git tag empty &&
make_files added &&
git add . &&
git commit -m added &&
make_files modified &&
git add . &&
git commit -m modified &&
make_files index &&
git add . &&
make_files worktree
'
test_expect_success '--max-depth is disallowed with wildcard pathspecs' '
test_must_fail git diff-tree --max-depth=0 HEAD^ HEAD -- "f*"
'
check_one() {
type=$1; shift
args=$1; shift
path=$1; shift
depth=$1; shift
test_expect_${expect:-success} "diff-$type $args, path=$path, depth=$depth" "
for i in $*; do echo \$i; done >expect &&
git diff-$type --max-depth=$depth --name-only $args -- $path >actual &&
test_cmp expect actual
"
}
# For tree comparisons, we expect to see subtrees at the boundary
# get their own entry.
check_trees() {
check_one tree "$*" '' 0 file one
check_one tree "$*" '' 1 file one/file one/two
check_one tree "$*" '' 2 file one/file one/two/file one/two/three
check_one tree "$*" '' 3 file one/file one/two/file one/two/three/file
check_one tree "$*" '' -1 file one/file one/two/file one/two/three/file
check_one tree "$*" one 0 one
check_one tree "$*" one 1 one/file one/two
check_one tree "$*" one 2 one/file one/two/file one/two/three
check_one tree "$*" one 3 one/file one/two/file one/two/three/file
check_one tree "$*" one/two 0 one/two
check_one tree "$*" one/two 1 one/two/file one/two/three
check_one tree "$*" one/two 2 one/two/file one/two/three/file
check_one tree "$*" one/two 2 one/two/file one/two/three/file
check_one tree "$*" one/two/three 0 one/two/three
check_one tree "$*" one/two/three 1 one/two/three/file
}
# But for index comparisons, we do not store subtrees at all, so we do not
# expect them.
check_index() {
check_one "$@" '' 0 file
check_one "$@" '' 1 file one/file
check_one "$@" '' 2 file one/file one/two/file
check_one "$@" '' 3 file one/file one/two/file one/two/three/file
check_one "$@" one 0
check_one "$@" one 1 one/file
check_one "$@" one 2 one/file one/two/file
check_one "$@" one 3 one/file one/two/file one/two/three/file
check_one "$@" one/two 0
check_one "$@" one/two 1 one/two/file
check_one "$@" one/two 2 one/two/file one/two/three/file
check_one "$@" one/two/three 0
check_one "$@" one/two/three 1 one/two/three/file
# Value '-1' for '--max-depth is the same as recursion without limit,
# and thus should always succeed.
local expect=
check_one "$@" '' -1 file one/file one/two/file one/two/three/file
}
# Check as a modification...
check_trees HEAD^ HEAD
# ...and as an addition...
check_trees empty HEAD
# ...and as a deletion.
check_trees HEAD empty
# We currently only implement max-depth for trees.
expect=failure
# Check index against a tree
check_index index "--cached HEAD"
# and index against the worktree
check_index files ""
expect=
test_expect_success 'find shortest path within embedded pathspecs' '
cat >expect <<-\EOF &&
one/file
one/two/file
one/two/three/file
EOF
git diff-tree --max-depth=2 --name-only HEAD^ HEAD -- one one/two >actual &&
test_cmp expect actual
'
test_done