authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-25 15:56:22 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-25 15:56:22 -07:00
log073d0debe593245c192e9f5ce595fac29494c9c4
treed8f68a8c330a1e7bfea7cc43912002a7112bbcf3
parent323e0de9e0a8128868f75dbd88c930ae178887bb
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

parseCommit: use mailmap


1 files changed, 4 insertions(+), 2 deletions(-)

git.zig+4-2
...@@ -157,7 +157,7 @@ pub fn revListAll(alloc: std.mem.Allocator, dir: nfs.Dir, from: CommitId, sub_pa...@@ -157,7 +157,7 @@ pub fn revListAll(alloc: std.mem.Allocator, dir: nfs.Dir, from: CommitId, sub_pa
157 return std.mem.trimEnd(u8, result.stdout, "\n");157 return std.mem.trimEnd(u8, result.stdout, "\n");
158}158}
159159
160pub fn parseCommit(alloc: std.mem.Allocator, commitfile: string) !Commit {160pub fn parseCommit(alloc: std.mem.Allocator, commitfile: string, mailmap: *const std.hash_map.StringHashMapUnmanaged([]const u8)) !Commit {
161 const t = tracer.trace(@src(), "", .{});161 const t = tracer.trace(@src(), "", .{});
162 defer t.end();162 defer t.end();
163163
...@@ -184,6 +184,8 @@ pub fn parseCommit(alloc: std.mem.Allocator, commitfile: string) !Commit {...@@ -184,6 +184,8 @@ pub fn parseCommit(alloc: std.mem.Allocator, commitfile: string) !Commit {
184 if (std.mem.eql(u8, k, "parent")) try parents.append(.{ .id = line[space + 1 ..][0..40] });184 if (std.mem.eql(u8, k, "parent")) try parents.append(.{ .id = line[space + 1 ..][0..40] });
185 }185 }
186 result.parents = try parents.toOwnedSlice();186 result.parents = try parents.toOwnedSlice();
187 result.author.email = mailmap.get(result.author.email) orelse result.author.email;
188 result.committer.email = mailmap.get(result.committer.email) orelse result.committer.email;
187 result.message = iter.rest();189 result.message = iter.rest();
188 return result;190 return result;
189}191}
...@@ -1093,7 +1095,7 @@ pub const Repository = struct {...@@ -1093,7 +1095,7 @@ pub const Repository = struct {
1093 if (try r.getObject(id.id, cache_behavior)) |obj| {1095 if (try r.getObject(id.id, cache_behavior)) |obj| {
1094 if (obj.type == .commit) {1096 if (obj.type == .commit) {
1095 errdefer if (cache_behavior == .no_cache) r.gpa.free(obj.content);1097 errdefer if (cache_behavior == .no_cache) r.gpa.free(obj.content);
1096 const commit = try parseCommit(r.gpa, obj.content);1098 const commit = try parseCommit(r.gpa, obj.content, &r.mailmap);
1097 try r.commits.put(r.gpa, id.id, commit);1099 try r.commits.put(r.gpa, id.id, commit);
1098 return .{ id, commit };1100 return .{ id, commit };
1099 }1101 }