srctree

Gregory Mullen parent 35e6b0bb 1d01ba51
move git.changeset into it's own file

inlinesplit
src/git.zig added: 34, removed: 29, total 5
@@ -20,6 +20,7 @@ pub const Commit = @import("git/commit.zig");
pub const Pack = @import("git/pack.zig");
pub const Tree = @import("git/tree.zig");
pub const Remote = @import("git/remote.zig");
 
pub const Error = error{
ReadError,
@@ -815,33 +816,6 @@ pub fn commitishRepo(rev: []const u8, repo: Repo) bool {
return false;
}
pub const ChangeSet = struct {
alloc: Allocator,
name: []const u8,
sha: SHA,
// Index into commit slice
commit_title: []const u8,
commit: []const u8,
timestamp: i64,
 
pub fn init(a: Allocator, name: []const u8, sha: SHA, msg: []const u8, ts: i64) !ChangeSet {
const commit = try a.dupe(u8, msg);
return ChangeSet{
.alloc = a,
.name = try a.dupe(u8, name),
.sha = sha,
.commit = commit,
.commit_title = if (std.mem.indexOf(u8, commit, "\n\n")) |i| commit[0..i] else commit,
.timestamp = ts,
};
}
 
pub fn raze(self: ChangeSet) void {
self.alloc.free(self.name);
self.alloc.free(self.commit);
}
};
 
test "hex tranlations" {
const one = "370303630b3fc631a0cb3942860fb6f77446e9c1";
var binbuf: [20]u8 = SHA.toBin(one.*);
@@ -20,6 +20,7 @@ pub const Commit = @import("git/commit.zig");
pub const Pack = @import("git/pack.zig");
pub const Tree = @import("git/tree.zig");
pub const Remote = @import("git/remote.zig");
pub const ChangeSet = @import("git/changeset.zig");
pub const Error = error{
ReadError,
@@ -815,33 +816,6 @@ pub fn commitishRepo(rev: []const u8, repo: Repo) bool {
return false;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test "hex tranlations" {
const one = "370303630b3fc631a0cb3942860fb6f77446e9c1";
var binbuf: [20]u8 = SHA.toBin(one.*);
filename was Deleted added: 34, removed: 29, total 5
@@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
 
const SHA = @import("../git.zig").SHA;
 
pub const ChangeSet = @This();
 
alloc: Allocator,
name: []const u8,
sha: SHA,
// Index into commit slice
commit_title: []const u8,
commit: []const u8,
timestamp: i64,
 
pub fn init(a: Allocator, name: []const u8, sha: SHA, msg: []const u8, ts: i64) !ChangeSet {
const commit = try a.dupe(u8, msg);
return ChangeSet{
.alloc = a,
.name = try a.dupe(u8, name),
.sha = sha,
.commit = commit,
.commit_title = if (std.mem.indexOf(u8, commit, "\n\n")) |i| commit[0..i] else commit,
.timestamp = ts,
};
}
 
pub fn raze(self: ChangeSet) void {
self.alloc.free(self.name);
self.alloc.free(self.commit);
}