Dave Jarvis' Repositories

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

Allows referencing objects inside of tag data

Author Dave Jarvis <email>
Date 2026-02-16 02:31:11 GMT-0800
Commit c8b214f4618b34e20f88723e3b3f82123c7ce986
Parent a1736fd
git/Git.php
$objects[$sha] = ['type' => $type, 'size' => strlen( $data )];
- if( $type === 1 ) {
+ if( $type === 1 ) { // Commit
if( preg_match( '/^tree ([0-9a-f]{40})/m', $data, $matches ) ) {
$this->collectObjectsRecursive( $matches[1], $objects, $visited );
}
-
if( preg_match( '/^parent ([0-9a-f]{40})/m', $data, $matches ) ) {
$this->collectObjectsRecursive( $matches[1], $objects, $visited );
}
- } elseif( $type === 2 ) {
+ } elseif( $type === 2 ) { // Tree
$position = 0;
$length = strlen( $data );
-
while( $position < $length ) {
$spacePos = strpos( $data, ' ', $position );
$nullPos = strpos( $data, "\0", $spacePos );
-
if( $spacePos === false || $nullPos === false ) break;
$entrySha = bin2hex( substr( $data, $nullPos + 1, 20 ) );
$this->collectObjectsRecursive( $entrySha, $objects, $visited );
-
$position = $nullPos + 21;
+ }
+ } elseif( $type === 4 ) { // Tag
+ if( preg_match( '/^object ([0-9a-f]{40})/m', $data, $matches ) ) {
+ $this->collectObjectsRecursive( $matches[1], $objects, $visited );
}
}
if( $this->isTreeData( $data ) ) {
return 2;
+ }
+
+ if( strpos( $data, "object " ) === 0 ) {
+ return 4;
}
Delta 10 lines added, 6 lines removed, 4-line increase