Dave Jarvis' Repositories

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

Updates file listing to include size and date

AuthorDave Jarvis <email>
Date2026-01-14 22:44:44 GMT-0800
Commit53f1a29bee6f733926ca0d009f1e92d99bc9827e
Parentac4480b
includes/repo_functions.php
if (empty($line)) continue;
if (preg_match('/^(\d+)\s+(blob|tree)\s+([a-f0-9]+)\s+(.+)$/', $line, $matches)) {
- $items[] = [
+ $item = [
'mode' => $matches[1],
'type' => $matches[2],
'hash' => $matches[3],
'name' => $matches[4]
];
+
+ // Get size for blobs
+ if ($item['type'] === 'blob') {
+ $sizeOutput = execGitRaw($repo, "cat-file -s " . escapeshellarg($item['hash']));
+ $item['size'] = (int)trim($sizeOutput);
+ }
+
+ // Get last modification time for this file
+ $filePath = $path ? $path . '/' . $item['name'] : $item['name'];
+ $mtimeOutput = execGitRaw($repo, "log -1 --format=%ct " . escapeshellarg($ref) . " -- " . escapeshellarg($filePath));
+ if (!empty($mtimeOutput)) {
+ $item['mtime'] = (int)trim($mtimeOutput);
+ }
+
+ $items[] = $item;
}
}
Delta16 lines added, 1 line removed, 15-line increase