download patch
commit 9746c5534dd277e310256217fb8670463cf3eef6
Author: tri <tri@thac.loan>
Date: Fri Oct 3 20:55:45 2025 +0700
skip weird objects reported by git-ls-tree
diff --git a/src/git.zig b/src/git.zig
index c8ebed3..c8cac10 100644
--- a/src/git.zig
+++ b/src/git.zig
pub fn walkTree(arena: mem.Allocator, dir: fs.Dir) !Walker {
// );
//}
-pub const ObjectType = enum { blob, commit, tree };
+pub const ObjectType = enum { blob, commit, tree, other };
pub fn objectType(arena: mem.Allocator, dir: fs.Dir, object_hash: []const u8) !ObjectType {
var proc = try std.process.Child.run(.{
pub fn objectType(arena: mem.Allocator, dir: fs.Dir, object_hash: []const u8) !O
return .tree;
}
- std.debug.panic("Unrecognized object type: {s} \"{s}\" - {s}", .{
- object_hash,
- result,
- proc.stderr,
- });
+ // I ran into a repo that had an empty folder, which `git ls-tree` listed
+ // as a "commit" object, but other commands like `git show` would say that
+ // same hash is invalid. I never figured out why that is, so just skip such
+ // cases for now.
+ return .other;
+ //std.debug.panic("Unrecognized object type: {s} \"{s}\" - {s}", .{
+ // object_hash,
+ // result,
+ // proc.stderr,
+ //});
}
/// Replicates git's simple heuristic: if there's a null byte in the first 8k
diff --git a/src/main.zig b/src/main.zig
index 1176acb..2e7285c 100644
--- a/src/main.zig
+++ b/src/main.zig
pub fn writeFilePage(
_ = out_dir.statFile(file_name) catch |err| {
switch (err) {
error.FileNotFound => {
+ const object_type = try git.objectType(arena, args.in_repo_dir, src_file.hash);
+ if (object_type != .blob) {
+ return;
+ }
+
println(" writing {s}: {s}/{s}", .{
args.repo_name,
constants.web_objects_path,
pub fn writeFilePage(
try utils.humanReadableSize(arena, src_file.size),
});
- const object_type = try git.objectType(arena, args.in_repo_dir, src_file.hash);
- if (object_type != .blob) {
- std.debug.panic("Not implemented: {any}\n", .{object_type});
- }
-
try writer.writeAll(
\\<pre class="blob-content">
\\