Dave Jarvis' Repositories

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

Ignores ignored files

Author Dave Jarvis <email>
Date 2026-02-20 12:20:02 GMT-0800
Commit d4227e1ece9de098e1aaa01f4070520d67596ff9
Parent df04ae2
git/GitRefs.php
if( $input === 'HEAD' && file_exists( $headFile ) ) {
- $head = trim( file_get_contents( $headFile ) );
+ $head = trim( file_get_contents( $headFile ) );
$result = strpos( $head, 'ref: ' ) === 0
? $this->resolve( substr( $head, 5 ) )
}
- if( empty( $found ) ) {
- $key = array_key_first( $branches );
- $found = $key
- ? [ 'name' => $key, 'hash' => $branches[$key] ]
- : [ 'name' => '', 'hash' => '' ];
+ if( empty( $found ) && !empty( $branches ) ) {
+ $key = array_key_first( $branches );
+ $found = [ 'name' => $key, 'hash' => $branches[$key] ];
+ } elseif( empty( $found ) ) {
+ $found = [ 'name' => '', 'hash' => '' ];
}
return $found;
}
public function scanRefs( string $prefix, callable $callback ): void {
$dir = "{$this->repoPath}/$prefix";
+
+ $this->traverseDirectory( $dir, $callback, '' );
+ }
+ private function traverseDirectory(
+ string $dir,
+ callable $callback,
+ string $subPath
+ ): void {
if( is_dir( $dir ) ) {
$files = array_diff( scandir( $dir ), ['.', '..'] );
+
foreach( $files as $file ) {
- $callback( $file, trim( file_get_contents( "$dir/$file" ) ) );
+ $path = "$dir/$file";
+ $name = $subPath === '' ? $file : "$subPath/$file";
+
+ if( is_dir( $path ) ) {
+ $this->traverseDirectory( $path, $callback, $name );
+ } elseif( is_file( $path ) ) {
+ $sha = trim( file_get_contents( $path ) );
+
+ if( preg_match( '/^[0-9a-f]{40}$/', $sha ) ) {
+ $callback( $name, $sha );
+ }
+ }
}
}
foreach( $paths as $ref ) {
$path = "{$this->repoPath}/$ref";
+
if( file_exists( $path ) ) {
$result = trim( file_get_contents( $path ) );
break;
}
}
if( $result === '' ) {
$packedPath = "{$this->repoPath}/packed-refs";
+
if( file_exists( $packedPath ) ) {
$result = $this->findInPackedRefs( $packedPath, $input );
}
+ }
+
+ if( !preg_match( '/^[0-9a-f]{40}$/', $result ) ) {
+ $result = '';
}
if( $line[0] !== '#' && $line[0] !== '^' ) {
$parts = explode( ' ', trim( $line ) );
+
if( count( $parts ) >= 2 && in_array( $parts[1], $targets ) ) {
$result = $parts[0];
Delta 34 lines added, 7 lines removed, 27-line increase