Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Attempts to resolve big clones again

Author Dave Jarvis <email>
Date 2026-02-20 01:28:40 GMT-0800
Commit fcdfba787b33114fa50671e578fa0b732ed2a2c0
Parent 793df32
git/Git.php
foreach( $wants as $sha ) {
- $objs = $this->collectObjectsRecursive( $sha, $objs, 0 );
+ $this->collectObjectsRecursive( $sha, $objs, 0 );
}
private function collectObjectsRecursive(
string $sha,
- array $objs,
+ array &$objs,
int $expectedType = 0
- ): array {
- $result = $objs;
+ ): void {
+ if( !isset( $objs[$sha] ) ) {
+ $type = $expectedType;
+ $data = '';
- if( !isset( $result[$sha] ) ) {
- $data = $this->read( $sha );
- $type = $expectedType === 0
- ? $this->getObjectType( $data )
- : $expectedType;
+ if( $type !== 3 ) {
+ $data = $this->read( $sha );
+ }
- $result[$sha] = [
+ if( $type === 0 ) {
+ $type = $this->getObjectType( $data );
+ }
+
+ $objs[$sha] = [
'type' => $type,
- 'size' => strlen( $data )
+ 'size' => $type === 3
+ ? $this->getObjectSize( $sha )
+ : strlen( $data )
];
if( $type === 1 ) {
$hasTree = preg_match( '/^tree ([0-9a-f]{40})/m', $data, $m );
if( $hasTree ) {
- $result = $this->collectObjectsRecursive( $m[1], $result, 2 );
+ $this->collectObjectsRecursive( $m[1], $objs, 2 );
}
if( $hasParents ) {
foreach( $m[1] as $parentSha ) {
- $result = $this->collectObjectsRecursive(
+ $this->collectObjectsRecursive(
$parentSha,
- $result,
+ $objs,
1
);
$pos = $eos + 21;
- $result = $this->collectObjectsRecursive(
+ $this->collectObjectsRecursive(
$s,
- $result,
+ $objs,
$nextType
);
}
}
- $isTagTarget = $type === 4 &&
- preg_match( '/^object ([0-9a-f]{40})/m', $data, $m );
+ if( $type === 4 ) {
+ $isTagTarget = preg_match( '/^object ([0-9a-f]{40})/m', $data, $m );
- if( $isTagTarget ) {
- $nextType = 1;
+ if( $isTagTarget ) {
+ $nextType = 1;
- if( preg_match( '/^type (commit|tree|blob|tag)/m', $data, $t ) ) {
- $map = [
- 'commit' => 1,
- 'tree' => 2,
- 'blob' => 3,
- 'tag' => 4
- ];
+ if( preg_match( '/^type (commit|tree|blob|tag)/m', $data, $t ) ) {
+ $map = [
+ 'commit' => 1,
+ 'tree' => 2,
+ 'blob' => 3,
+ 'tag' => 4
+ ];
- $nextType = $map[$t[1]] ?? 1;
- }
+ $nextType = $map[$t[1]] ?? 1;
+ }
- $result = $this->collectObjectsRecursive(
- $m[1],
- $result,
- $nextType
- );
+ $this->collectObjectsRecursive(
+ $m[1],
+ $objs,
+ $nextType
+ );
+ }
}
}
-
- return $result;
}
Delta 41 lines added, 36 lines removed, 5-line increase