authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-04-12 13:35:48 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-04-12 13:35:48 -07:00
loge7865d3412c7f31fbdf3f4b4513238bbff6055e7
tree9a098b9cd451562f9fa81e2debfdc3aed28353f2
parentd4eda1fd309d4efb29b98559c0f6aa4716b4121b
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add tracer.trace() calls to Repository


1 files changed, 30 insertions(+), 0 deletions(-)

git.zig+30
......@@ -951,6 +951,9 @@ pub const Repository = struct {
951951 }
952952
953953 pub fn getObject(r: *Repository, arena: std.mem.Allocator, oid: Id) !?GitObject {
954 const t = tracer.trace(@src(), " {s}", .{oid});
955 defer t.end();
956
954957 if (r.unpacked_objects.get(oid)) |obj| {
955958 return obj;
956959 }
......@@ -1043,6 +1046,9 @@ pub const Repository = struct {
10431046 }
10441047
10451048 fn getPackedObject(r: *Repository, maybe_oid: ?Id, pack_index: usize, pack_offset: usize) !GitObject {
1049 const t = tracer.trace(@src(), " {?s} {d} {d}", .{ maybe_oid, pack_index, pack_offset });
1050 defer t.end();
1051
10461052 const pack_content = r.pack_content.values()[pack_index];
10471053 if (!std.mem.eql(u8, pack_content[0..4], "PACK")) return error.InvalidGitPack;
10481054 const pack_version = std.mem.readInt(u32, pack_content[4..][0..4], .big);
......@@ -1180,6 +1186,9 @@ pub const Repository = struct {
11801186 };
11811187
11821188 pub fn getCommit(r: *Repository, arena: std.mem.Allocator, id: CommitId) !?struct { CommitId, Commit } {
1189 const t = tracer.trace(@src(), " {s}", .{id.id});
1190 defer t.end();
1191
11831192 if (r.commits.getPtr(id.id)) |val| {
11841193 return .{ id, val.* };
11851194 }
......@@ -1194,6 +1203,9 @@ pub const Repository = struct {
11941203 }
11951204
11961205 pub fn getTree(r: *Repository, arena: std.mem.Allocator, id: TreeId) !?struct { TreeId, Tree } {
1206 const t = tracer.trace(@src(), " {s}", .{id.id});
1207 defer t.end();
1208
11971209 if (r.trees.getPtr(id.id)) |val| {
11981210 return .{ id, val.* };
11991211 }
......@@ -1241,6 +1253,9 @@ pub const Repository = struct {
12411253 }
12421254
12431255 pub fn getTag(r: *Repository, arena: std.mem.Allocator, id: TagId) !?struct { TagId, Tag } {
1256 const t = tracer.trace(@src(), " {s}", .{id.id});
1257 defer t.end();
1258
12441259 if (r.tags.getPtr(id.id)) |val| {
12451260 return .{ id, val.* };
12461261 }
......@@ -1255,14 +1270,23 @@ pub const Repository = struct {
12551270 }
12561271
12571272 pub fn getHeads(r: *Repository, arena: std.mem.Allocator) ![]Ref {
1273 const t = tracer.trace(@src(), "", .{});
1274 defer t.end();
1275
12581276 return r.getRefs(arena, "heads");
12591277 }
12601278
12611279 pub fn getTags(r: *Repository, arena: std.mem.Allocator) ![]Ref {
1280 const t = tracer.trace(@src(), "", .{});
1281 defer t.end();
1282
12621283 return r.getRefs(arena, "tags");
12631284 }
12641285
12651286 pub fn getRefs(r: *Repository, arena: std.mem.Allocator, comptime kind: [:0]const u8) ![]Ref {
1287 const t = tracer.trace(@src(), "", .{});
1288 defer t.end();
1289
12661290 var map: std.StringArrayHashMapUnmanaged(Id) = .empty;
12671291 try r.addPackedRefs(&map, arena, kind);
12681292 try r.addDirRefs(&map, arena, kind);
......@@ -1273,6 +1297,9 @@ pub const Repository = struct {
12731297 }
12741298
12751299 fn addPackedRefs(r: *Repository, map: *std.StringArrayHashMapUnmanaged(Id), arena: std.mem.Allocator, comptime kind: [:0]const u8) !void {
1300 const t = tracer.trace(@src(), "", .{});
1301 defer t.end();
1302
12761303 var file = try r.gitdir.openFile("packed-refs", .{});
12771304 defer file.close();
12781305 const content = try file.mmap();
......@@ -1292,6 +1319,9 @@ pub const Repository = struct {
12921319 }
12931320
12941321 fn addDirRefs(r: *Repository, map: *std.StringArrayHashMapUnmanaged(Id), arena: std.mem.Allocator, comptime kind: [:0]const u8) !void {
1322 const t = tracer.trace(@src(), "", .{});
1323 defer t.end();
1324
12951325 var dir = try r.gitdir.openDir("refs/" ++ kind, .{});
12961326 defer dir.close();
12971327 var walker = try dir.walk(arena);