navid/veins / commit
16b30ee10df1
Navid M <navidmomtahen@gmail.com> · 2026-11-25
parents: f43cf34bbf18
Browse files at this commit · Download source
--- a/src/src/chunking/fastcdc.sx+++ b/src/src/chunking/fastcdc.sx@@ -11,9 +11,9 @@ val lists = use("../core/lists.sx") pub val (- MIN_SIZE: usize = 16384- AVG_SIZE: usize = 65536- MAX_SIZE: usize = 262144+ MIN_SIZE: usize = 16384+ AVG_SIZE: usize = 65536+ MAX_SIZE: usize = 262144 NORMALIZATION: usize = 2 ) --- a/src/src/chunking/gear.sx+++ b/src/src/chunking/gear.sx@@ -76,4 +76,3 @@ /// Byte view of the frozen table for fast FFI-free indexing. pub val GEAR_RAW: ref u8 = @embed("gear.bin")---- a/src/src/cli/git_cmd.sx+++ b/src/src/cli/git_cmd.sx@@ -64,16 +64,12 @@ return 1 } }- match source {- some src => {- val prepared = mirror.prepare(repo, src)- if prepared != 0 {- stdio.eprint("vn: cannot prepare git mirror (code {d})\n", {prepared})- layout.free_repo(repo)- return 1- }- }- none => {+ if source is some src {+ val prepared = mirror.prepare(repo, src)+ if prepared != 0 {+ stdio.eprint("vn: cannot prepare git mirror (code {d})\n", {prepared})+ layout.free_repo(repo)+ return 1 } } val status: i32 = import.run(repo)--- a/src/src/cli/init_cmd.sx+++ b/src/src/cli/init_cmd.sx@@ -12,20 +12,16 @@ ok repo => { stdio.print("initialized vein repository at {s}\n", {layout.root_view(repo)}) val mut_source = source- match mut_source {- some src => {- val prepared: i32 = mirror.prepare(repo, src)- if prepared != 0 {- stdio.eprint("vn: cannot prepare git mirror (code {d})\n", {prepared})- layout.free_repo(repo)- return 1- }- val status: i32 = import.run(repo)+ if mut_source is some src {+ val prepared: i32 = mirror.prepare(repo, src)+ if prepared != 0 {+ stdio.eprint("vn: cannot prepare git mirror (code {d})\n", {prepared}) layout.free_repo(repo)- return status- }- none => {+ return 1 }+ val status: i32 = import.run(repo)+ layout.free_repo(repo)+ return status } layout.free_repo(repo) return 0--- a/src/src/crypto/blake3.sx+++ b/src/src/crypto/blake3.sx@@ -233,7 +233,11 @@ extern (C) fn vein_blake3(data: ref u8, len: usize, out: ref u8) void = "vein_blake3" extern (C) fn vein_blake3_state_size() usize = "vein_blake3_state_size" extern (C) fn vein_blake3_init(state: ref void) void = "vein_blake3_init"-extern (C) fn vein_blake3_update(state: ref void, data: ref u8, len: usize) void = "vein_blake3_update"+extern (C) fn vein_blake3_update(+ state: ref void,+ data: ref u8,+ len: usize+) void = "vein_blake3_update" extern (C) fn vein_blake3_final(state: ref void, out: ref u8) void = "vein_blake3_final" pub fn hasher_state_size() usize = trust {--- a/src/src/git/format.sx+++ b/src/src/git/format.sx@@ -557,7 +557,7 @@ pub fn mode_kind(mode: bytes.Bytes) u8 = trust { if bytes.Bytes.eql(mode, bytes.bytes(c"40000", 5))- || bytes.Bytes.eql(mode, bytes.bytes(c"040000", 6)) {+ || bytes.Bytes.eql(mode, bytes.bytes(c"040000", 6)) { return tree.KIND_SUBTREE } if bytes.Bytes.eql(mode, bytes.bytes(c"120000", 6)) {@@ -623,30 +623,22 @@ break } val kv_opt = parse_header_line(line)- match kv_opt {- some kv => {- if bytes.Bytes.eql(kv.key, bytes.bytes(c"object", 6)) {- val oid_opt = oid_from_hex(kv.value)- match oid_opt {- some oid => {- out.target = oid- }- none => {- }- }- } elif bytes.Bytes.eql(kv.key, bytes.bytes(c"type", 4)) {- if bytes.Bytes.eql(kv.value, bytes.bytes(c"commit", 6)) {- out.target_kind = object.KIND_COMMIT- } elif bytes.Bytes.eql(kv.value, bytes.bytes(c"tree", 4)) {- out.target_kind = object.KIND_TREE- } elif bytes.Bytes.eql(kv.value, bytes.bytes(c"blob", 4)) {- out.target_kind = object.KIND_BLOB- } elif bytes.Bytes.eql(kv.value, bytes.bytes(c"tag", 3)) {- out.target_kind = object.KIND_TAG- }+ if kv_opt is some kv {+ if bytes.Bytes.eql(kv.key, bytes.bytes(c"object", 6)) {+ val oid_opt = oid_from_hex(kv.value)+ if oid_opt is some oid {+ out.target = oid }- }- none => {+ } elif bytes.Bytes.eql(kv.key, bytes.bytes(c"type", 4)) {+ if bytes.Bytes.eql(kv.value, bytes.bytes(c"commit", 6)) {+ out.target_kind = object.KIND_COMMIT+ } elif bytes.Bytes.eql(kv.value, bytes.bytes(c"tree", 4)) {+ out.target_kind = object.KIND_TREE+ } elif bytes.Bytes.eql(kv.value, bytes.bytes(c"blob", 4)) {+ out.target_kind = object.KIND_BLOB+ } elif bytes.Bytes.eql(kv.value, bytes.bytes(c"tag", 3)) {+ out.target_kind = object.KIND_TAG+ } } } pos = line_end + 1--- a/src/src/git/import.sx+++ b/src/src/git/import.sx@@ -123,7 +123,11 @@ val current: mut bytes.Bytes = bytes.Bytes.dup(start) for { val obj_opt = object.read(git, current)- val obj: mut object.Object = object.Object{kind: 0, body: bytes.empty(), alloc: bytes.empty()}+ val obj: mut object.Object = object.Object{+ kind: 0,+ body: bytes.empty(),+ alloc: bytes.empty()+ } match obj_opt { ok o => { obj = o@@ -339,7 +343,11 @@ return some out2 } -fn add_branch_target(list: mut list[ref ImportNamedTarget], name: bytes.Bytes, oid: bytes.Bytes) void = trust {+fn add_branch_target(+ list: mut list[ref ImportNamedTarget],+ name: bytes.Bytes,+ oid: bytes.Bytes+) void = trust { val t: mut ref ImportNamedTarget = @alloc(@sizeof(ImportNamedTarget)) as ref ImportNamedTarget t.name = name t.oid = oid@@ -657,24 +665,16 @@ val tips: mut list[bytes.Bytes] = lists.new[bytes.Bytes]() for b in refset.branches { val peeled = peel_to_commit(ctx.git, b.oid)- match peeled {- some c => {- add_branch_target(branches, b.name, c)- @append(tips, bytes.Bytes.dup(c))- }- none => {- }+ if peeled is some c {+ add_branch_target(branches, b.name, c)+ @append(tips, bytes.Bytes.dup(c)) } } for t in refset.tags { val peeled2 = peel_to_commit(ctx.git, t.oid)- match peeled2 {- some c2 => {- add_branch_target(tags, t.name, c2)- @append(tips, bytes.Bytes.dup(c2))- }- none => {- }+ if peeled2 is some c2 {+ add_branch_target(tags, t.name, c2)+ @append(tips, bytes.Bytes.dup(c2)) } } val head_commit: mut option[bytes.Bytes] = none@@ -681,12 +681,8 @@ if refset.head.len > 0 { val head_peeled = peel_to_commit(ctx.git, refset.head) head_commit = head_peeled- match head_peeled {- some h => {- @append(tips, bytes.Bytes.dup(h))- }- none => {- }+ if head_peeled is some h {+ @append(tips, bytes.Bytes.dup(h)) } } @@ -708,7 +704,11 @@ } oidmap.put(seen, oid, bytes.empty()) val obj_opt = object.read(ctx.git, oid)- val obj: mut object.Object = object.Object{kind: 0, body: bytes.empty(), alloc: bytes.empty()}+ val obj: mut object.Object = object.Object{+ kind: 0,+ body: bytes.empty(),+ alloc: bytes.empty()+ } match obj_opt { ok o => { obj = o@@ -786,7 +786,10 @@ match idx_opt { some pidx => { if pidx < n {- val deg_ptr: ref u32 = @ptradd(indegree as ref void, (i2 * 4) as i64) as ref u32+ val deg_ptr: ref u32 = @ptradd(+ indegree as ref void,+ (i2 * 4) as i64+ ) as ref u32 @store32(deg_ptr, (@load32(deg_ptr) + 1) as i32) val child_list = @get(children, pidx) if child_list is some cl {@@ -1021,22 +1024,14 @@ for b in branches { val id = get_id(ctx.commits_map, b.oid)- match id {- some bid => {- set_bookmark(v, b.name, bid)- }- none => {- }+ if id is some bid {+ set_bookmark(v, b.name, bid) } } for t in tags { val id = get_id(ctx.commits_map, t.oid)- match id {- some tid => {- set_tag(v, t.name, tid)- }- none => {- }+ if id is some tid {+ set_tag(v, t.name, tid) } } sort_bookmarks(v.bookmarks)@@ -1046,23 +1041,15 @@ val new_heads: mut list[objid.Id] = lists.new[objid.Id]() for b in branches { val id = get_id(ctx.commits_map, b.oid)- match id {- some bid => {- add_unique_head(new_heads, bid)- }- none => {- }+ if id is some bid {+ add_unique_head(new_heads, bid) } } if @len(new_heads) == 0 { for t in tags { val id = get_id(ctx.commits_map, t.oid)- match id {- some tid => {- add_unique_head(new_heads, tid)- }- none => {- }+ if id is some tid {+ add_unique_head(new_heads, tid) } } }@@ -1206,7 +1193,10 @@ } } - stdio.eprint("vn: imported {d} commits, {d} trees, {d} blobs\n", {ctx.new_commits, ctx.new_trees, ctx.new_blobs})+ stdio.eprint(+ "vn: imported {d} commits, {d} trees, {d} blobs\n",+ {ctx.new_commits, ctx.new_trees, ctx.new_blobs}+ ) if old_encoded.ptr != none { val op3: mut ref void = old_encoded.ptr as ref void@@ -1263,4 +1253,3 @@ } } }---- a/src/src/git/map.sx+++ b/src/src/git/map.sx@@ -21,7 +21,10 @@ return files.with_suffix(base, suffix) } -pub fn load_map(repo: layout.Repo, name: str.StringView) result[oidmap.OidMap, object.GitError] = trust {+pub fn load_map(+ repo: layout.Repo,+ name: str.StringView+) result[oidmap.OidMap, object.GitError] = trust { val base: str.StringView = layout.git_map_dir(repo) val suffix: str.StringView = str.from_cstr(c".map") val fname: str.StringView = files.with_suffix(name, suffix)@@ -46,9 +49,9 @@ return err object.GitError.Corrupt } val count: u32 = (bytes.Bytes.at(data, 5) as u32)- | ((bytes.Bytes.at(data, 6) as u32) << 8)- | ((bytes.Bytes.at(data, 7) as u32) << 16)- | ((bytes.Bytes.at(data, 8) as u32) << 24)+ | ((bytes.Bytes.at(data, 6) as u32) << 8)+ | ((bytes.Bytes.at(data, 7) as u32) << 16)+ | ((bytes.Bytes.at(data, 8) as u32) << 24) val need: u64 = 9 as u64 + (count as u64) * 52 as u64 if need != data.len as u64 { files.free_buffer(data)--- a/src/src/git/mirror.sx+++ b/src/src/git/mirror.sx@@ -34,7 +34,10 @@ } val raw: bytes.Bytes = bytes.Bytes.slice(data, 8, data.len) val end: mut usize = raw.len- for end > 0 && (bytes.Bytes.at(raw, end - 1) == 10 || bytes.Bytes.at(raw, end - 1) == 13) {+ for end > 0 && (bytes.Bytes.at(+ raw,+ end - 1+ ) == 10 || bytes.Bytes.at(raw, end - 1) == 13) { end-- } val value: bytes.Bytes = bytes.Bytes.slice(raw, 0, end)--- a/src/src/git/object.sx+++ b/src/src/git/object.sx@@ -6,11 +6,11 @@ lib "z" lib "crypto" -val str = use("std/string")-val bytes = use("../core/bytes.sx")-val buf = use("../core/buf.sx")-val lists = use("../core/lists.sx")-val files = use("../io/files.sx")+val str = use("std/string")+val bytes = use("../core/bytes.sx")+val buf = use("../core/buf.sx")+val lists = use("../core/lists.sx")+val files = use("../io/files.sx") pub enum GitError = { NotFound@@ -58,7 +58,7 @@ alloc: bytes.Bytes } -pub fn free_object(o: Object) void= trust {+pub fn free_object(o: Object) void = trust { if o.alloc.ptr != none { val p: mut ref void = o.alloc.ptr as ref void @free(p)@@ -78,27 +78,32 @@ packs: list[ref GitPack] } -extern (C) fn uncompress(dest: ref u8, dest_len: ref u64, source: ref u8, source_len: u64) i32 = "uncompress"+extern (C) fn uncompress(+ dest: ref u8,+ dest_len: ref u64,+ source: ref u8,+ source_len: u64+) i32 = "uncompress" fn be32_at(data: bytes.Bytes, off: usize) u32 = trust { val p: ref u8 = @ptradd(data.ptr, off as i64) return ((@load8(p) as u32) << 24) | ((@load8(@ptradd(p, 1)) as u32) << 16)- | ((@load8(@ptradd(p, 2)) as u32) << 8) | (@load8(@ptradd(p, 3)) as u32)+ | ((@load8(@ptradd(p, 2)) as u32) << 8) | (@load8(@ptradd(p, 3)) as u32) } -fn be64_at(data: bytes.Bytes, off: usize) u64= trust {+fn be64_at(data: bytes.Bytes, off: usize) u64 = trust { val p: ref u8 = @ptradd(data.ptr, off as i64) val hi: u64 = ((@load8(p) as u64) << 56) | ((@load8(@ptradd(p, 1)) as u64) << 48)- | ((@load8(@ptradd(p, 2)) as u64) << 40) | ((@load8(@ptradd(p, 3)) as u64) << 32)+ | ((@load8(@ptradd(p, 2)) as u64) << 40) | ((@load8(@ptradd(p, 3)) as u64) << 32) val lo: u64 = ((@load8(@ptradd(p, 4)) as u64) << 24) | ((@load8(@ptradd(p, 5)) as u64) << 16)- | ((@load8(@ptradd(p, 6)) as u64) << 8) | (@load8(@ptradd(p, 7)) as u64)+ | ((@load8(@ptradd(p, 6)) as u64) << 8) | (@load8(@ptradd(p, 7)) as u64) return hi | lo } extern (C) fn SHA1(data: ref u8, len: usize, out: ref u8) ref u8 = "SHA1" -fn sha1_of(data: bytes.Bytes) option[bytes.Bytes]= trust {+fn sha1_of(data: bytes.Bytes) option[bytes.Bytes] = trust { val out: ref u8 = @alloc(20) as ref u8 val r: ref u8 = SHA1(data.ptr, data.len, out) if r == none {@@ -108,7 +113,7 @@ return some bytes.bytes(out, 20) } -pub fn free_digest(d: bytes.Bytes) void= trust {+pub fn free_digest(d: bytes.Bytes) void = trust { if d.ptr != none { val p: mut ref void = d.ptr as ref void @free(p)@@ -115,7 +120,7 @@ } } -fn put_decimal(b: mut buf.Buf, v: u64) void= trust {+fn put_decimal(b: mut buf.Buf, v: u64) void = trust { if v == 0 { buf.Buf.put_u8(b, 48) return@@ -169,7 +174,7 @@ } /// Git object hash: SHA-1("<kind> <length>\0" || body).-pub fn object_hash(kind: u8, body: bytes.Bytes) option[bytes.Bytes]= trust {+pub fn object_hash(kind: u8, body: bytes.Bytes) option[bytes.Bytes] = trust { val b: mut buf.Buf = buf.new(body.len + 32) buf.Buf.put_bytes(b, bytes.from_cstr(kind_name(kind).ptr)) buf.Buf.put_u8(b, 32)@@ -181,7 +186,7 @@ return out } -fn verify_hash(oid: bytes.Bytes, kind: u8, body: bytes.Bytes) bool= trust {+fn verify_hash(oid: bytes.Bytes, kind: u8, body: bytes.Bytes) bool = trust { val got = object_hash(kind, body) match got { some h => {@@ -195,7 +200,7 @@ } } -fn inflate_exact(input: bytes.Bytes, expected: usize) option[bytes.Bytes]= trust {+fn inflate_exact(input: bytes.Bytes, expected: usize) option[bytes.Bytes] = trust { val cap: usize = expected + 1 val dst: ref u8 = @alloc(cap) as ref u8 @memset(dst as ref void, 0, cap)@@ -216,7 +221,7 @@ return some bytes.bytes(dst, expected) } -fn inflate_unknown(input: bytes.Bytes) option[bytes.Bytes]= trust {+fn inflate_unknown(input: bytes.Bytes) option[bytes.Bytes] = trust { val base: mut usize = input.len * 3 + 4096 for base <= 1073741824 { val dst: ref u8 = @alloc(base + 1) as ref u8@@ -244,7 +249,7 @@ return (87 + n) as u8 } -fn oid_hex(oid: bytes.Bytes) ref u8= trust {+fn oid_hex(oid: bytes.Bytes) ref u8 = trust { val out: ref u8 = @alloc(41) as ref u8 val i: mut usize = 0 for i < 20 {@@ -303,7 +308,7 @@ return none } -fn apply_delta(base: bytes.Bytes, delta: bytes.Bytes) option[bytes.Bytes]= trust {+fn apply_delta(base: bytes.Bytes, delta: bytes.Bytes) option[bytes.Bytes] = trust { val src_opt = read_delta_varint(delta, 0) val src_size: mut u64 = 0 val p: mut usize = 0@@ -427,7 +432,11 @@ @free(out as ref void) return none }- @memcpy(@ptradd(out, written as i64) as ref void, @ptradd(delta.ptr, p as i64) as ref void, n)+ @memcpy(+ @ptradd(out, written as i64) as ref void,+ @ptradd(delta.ptr, p as i64) as ref void,+ n+ ) p = p + n written = written + n }@@ -461,11 +470,11 @@ return none } -fn offset_at(pack: ref GitPack, i: usize) u64= trust {+fn offset_at(pack: ref GitPack, i: usize) u64 = trust { return @load64(@ptradd(pack.offsets, (i * 8) as i64)) as u64 } -fn read_at(repo: GitRepo, pack: ref GitPack, start: u64) result[Object, GitError]= trust {+fn read_at(repo: GitRepo, pack: ref GitPack, start: u64) result[Object, GitError] = trust { val data: bytes.Bytes = pack.data val pos: mut usize = start as usize if pos >= data.len {@@ -585,7 +594,7 @@ return ok Object{kind: base_kind, body: merged, alloc: merged} } -fn read_loose(repo: GitRepo, oid: bytes.Bytes) option[Object]= trust {+fn read_loose(repo: GitRepo, oid: bytes.Bytes) option[Object] = trust { val hex: ref u8 = oid_hex(oid) val objroot: str.StringView = files.join(repo.git_dir, str.from_cstr(c"objects")) val dirname: str.StringView = str.view(hex, 2)@@ -664,17 +673,13 @@ return some o } -pub fn read(repo: GitRepo, oid: bytes.Bytes) result[Object, GitError]= trust {+pub fn read(repo: GitRepo, oid: bytes.Bytes) result[Object, GitError] = trust { pre { oid_len: oid.len == 20 } val loose = read_loose(repo, oid)- match loose {- some o => {- return ok o- }- none => {- }+ if loose is some o {+ return ok o } val i: mut usize = 0 for i < @len(repo.packs) {@@ -709,7 +714,11 @@ return none } -fn parse_idx(data: bytes.Bytes, pack_count: usize, pack_trailer: bytes.Bytes) result[ref GitPack, GitError]= trust {+fn parse_idx(+ data: bytes.Bytes,+ pack_count: usize,+ pack_trailer: bytes.Bytes+) result[ref GitPack, GitError] = trust { if data.len < 40 { return err GitError.Corrupt }@@ -737,10 +746,10 @@ } val is_v2: bool = data.len >= 8- && bytes.Bytes.at(data, 0) == 255- && bytes.Bytes.at(data, 1) == 116- && bytes.Bytes.at(data, 2) == 79- && bytes.Bytes.at(data, 3) == 99+ && bytes.Bytes.at(data, 0) == 255+ && bytes.Bytes.at(data, 1) == 116+ && bytes.Bytes.at(data, 2) == 79+ && bytes.Bytes.at(data, 3) == 99 val fanout_off: mut usize = 0 if is_v2 { fanout_off = 8@@ -827,7 +836,10 @@ return ok p } -fn open_pack(pack_path: str.StringView, idx_path: str.StringView) result[ref GitPack, GitError]= trust {+fn open_pack(+ pack_path: str.StringView,+ idx_path: str.StringView+) result[ref GitPack, GitError] = trust { val pdata_opt = files.read_all(pack_path) val pdata: mut bytes.Bytes = bytes.empty() match pdata_opt {@@ -896,7 +908,7 @@ return ok p } -pub fn open(git_dir: str.StringView) result[GitRepo, GitError]= trust {+pub fn open(git_dir: str.StringView) result[GitRepo, GitError] = trust { val packs: mut list[ref GitPack] = lists.new[ref GitPack]() val pack_dir: str.StringView = files.join(git_dir, str.from_cstr(c"objects/pack")) if files.exists_dir(pack_dir) {@@ -940,7 +952,7 @@ return ok GitRepo{git_dir: git_dir, packs: packs} } -pub fn free_pack(p: ref GitPack) void= trust {+pub fn free_pack(p: ref GitPack) void = trust { files.free_buffer(p.data) if p.oids != none { @free(p.oids as ref void)@@ -954,7 +966,7 @@ @free(p as ref void) } -pub fn free(repo: mut GitRepo) void= trust {+pub fn free(repo: mut GitRepo) void = trust { for p in repo.packs { free_pack(p) }@@ -964,4 +976,3 @@ } repo.git_dir = str.view(none, 0) }---- a/src/src/git/oidmap.sx+++ b/src/src/git/oidmap.sx@@ -120,7 +120,10 @@ val i: mut usize = 0 for i < old_cap { if @load8(@ptradd(old_slots, (i * SLOT_LEN) as i64)) != 0 {- val op: bytes.Bytes = bytes.bytes(@ptradd(old_slots, (i * SLOT_LEN + 1) as i64), OID_LEN)+ val op: bytes.Bytes = bytes.bytes(+ @ptradd(old_slots, (i * SLOT_LEN + 1) as i64),+ OID_LEN+ ) val vp: bytes.Bytes = bytes.bytes( @ptradd(old_slots, (i * SLOT_LEN + 1 + OID_LEN) as i64), VALUE_LEN--- a/src/src/git/refs.sx+++ b/src/src/git/refs.sx@@ -145,15 +145,11 @@ val hex: bytes.Bytes = bytes.Bytes.slice(line, 0, space) val name: bytes.Bytes = bytes.Bytes.slice(line, space + 1, line.len) val oid_opt = parse_hex_oid(hex)- match oid_opt {- some oid => {- if starts_with(name, bytes.bytes(c"refs/heads/", 11)) {- replace_ref(branches, short_name(name, 11), oid)- } elif starts_with(name, bytes.bytes(c"refs/tags/", 10)) {- replace_ref(tags, short_name(name, 10), oid)- }- }- none => {+ if oid_opt is some oid {+ if starts_with(name, bytes.bytes(c"refs/heads/", 11)) {+ replace_ref(branches, short_name(name, 11), oid)+ } elif starts_with(name, bytes.bytes(c"refs/tags/", 10)) {+ replace_ref(tags, short_name(name, 10), oid) } } }@@ -182,18 +178,10 @@ read_ref_dir(base, child_rel, refs) } else { val content_opt = read_line_file(child_path)- match content_opt {- some content => {- val oid_opt = parse_hex_oid(content)- match oid_opt {- some oid => {- replace_ref(refs, bytes.Bytes.dup(bytes.from_cstr(child_rel.ptr)), oid)- }- none => {- }- }- }- none => {+ if content_opt is some content {+ val oid_opt = parse_hex_oid(content)+ if oid_opt is some oid {+ replace_ref(refs, bytes.Bytes.dup(bytes.from_cstr(child_rel.ptr)), oid) } } }@@ -206,7 +194,11 @@ } } -fn resolve_head(git_dir: str.StringView, branches: list[ref Ref], tags: list[ref Ref]) bytes.Bytes = trust {+fn resolve_head(+ git_dir: str.StringView,+ branches: list[ref Ref],+ tags: list[ref Ref]+) bytes.Bytes = trust { val path: str.StringView = files.join(git_dir, str.from_cstr(c"HEAD")) val data_opt = read_line_file(path) files.free_path(path)@@ -224,25 +216,17 @@ if starts_with(name, bytes.bytes(c"refs/heads/", 11)) { val short: bytes.Bytes = short_name(name, 11) val found = find_ref(branches, short)- match found {- some oid => {- files.free_buffer(data)- return bytes.Bytes.dup(oid)- }- none => {- }+ if found is some oid {+ files.free_buffer(data)+ return bytes.Bytes.dup(oid) } } if starts_with(name, bytes.bytes(c"refs/tags/", 10)) { val short2: bytes.Bytes = short_name(name, 10) val found2 = find_ref(tags, short2)- match found2 {- some oid => {- files.free_buffer(data)- return bytes.Bytes.dup(oid)- }- none => {- }+ if found2 is some oid {+ files.free_buffer(data)+ return bytes.Bytes.dup(oid) } } files.free_buffer(data)--- a/src/src/store/state.sx+++ b/src/src/store/state.sx@@ -70,7 +70,10 @@ } } -pub fn read_operation(handles: list[ref store.Handle], id: objid.Id) option[ref operation.Operation] = trust {+pub fn read_operation(+ handles: list[ref store.Handle],+ id: objid.Id+) option[ref operation.Operation] = trust { val body_opt = read_body(handles, id, types.OPERATION) val body: mut bytes.Bytes = bytes.empty() match body_opt {@@ -167,12 +170,8 @@ val names: list[ref u8] = files.list_dir(dir) for n in names { val parsed = parse_head_name(n)- match parsed {- some id => {- @append(out, id)- }- none => {- }+ if parsed is some id {+ @append(out, id) } } files.free_names(names)@@ -181,7 +180,10 @@ return out } -pub fn current_view(repo: layout.Repo, handles: list[ref store.Handle]) option[ref view.View] = trust {+pub fn current_view(+ repo: layout.Repo,+ handles: list[ref store.Handle]+) option[ref view.View] = trust { val hs: list[objid.Id] = heads(repo) if @len(hs) == 0 { return none--- a/src/src/store/writer.sx+++ b/src/src/store/writer.sx@@ -4,20 +4,20 @@ /// the header count is patched, the pack trailer is hashed by streaming over /// the file, and the index is written from the collected record metadata. -val str = use("std/string")-val time = use("std/time")-val bytes = use("../core/bytes.sx")-val buf = use("../core/buf.sx")-val lists = use("../core/lists.sx")-val objid = use("../object/id.sx")-val records = use("records.sx")-val idmap = use("idmap.sx")-val index = use("index.sx")-val zstd = use("zstd.sx")-val layout = use("../store/layout.sx")-val files = use("../io/files.sx")-val native = use("../io/native.sx")-val b3 = use("../crypto/blake3.sx")+val str = use("std/string")+val time = use("std/time")+val bytes = use("../core/bytes.sx")+val buf = use("../core/buf.sx")+val lists = use("../core/lists.sx")+val objid = use("../object/id.sx")+val records = use("records.sx")+val idmap = use("idmap.sx")+val index = use("index.sx")+val zstd = use("zstd.sx")+val layout = use("../store/layout.sx")+val files = use("../io/files.sx")+val native = use("../io/native.sx")+val b3 = use("../crypto/blake3.sx") pub type Writer = { tmp_path: mut str.StringView@@ -260,7 +260,13 @@ val index_bytes: bytes.Bytes = index.encode(w.metas, trailer) val idx_tmp_name: str.StringView = files.with_suffix(pack_name, str.from_cstr(c".vidx.tmp")) val idx_tmp: str.StringView = files.join(w.tmp_dir, idx_tmp_name)- val wrote_index: bool = native.write_atomic(idx_tmp, idx_final, w.tmp_dir, w.packs_dir, index_bytes)+ val wrote_index: bool = native.write_atomic(+ idx_tmp,+ idx_final,+ w.tmp_dir,+ w.packs_dir,+ index_bytes+ ) val idx_buf: mut ref void = index_bytes.ptr as ref void @free(idx_buf) files.free_path(idx_tmp_name)--- a/src/src/worktree/checkout.sx+++ b/src/src/worktree/checkout.sx@@ -1,23 +1,23 @@ /// Parallel, path-safe checkout from a vein tree into the working directory. -val str = use("std/string")-val stdio = use("std/stdio")+val str = use("std/string")+val stdio = use("std/stdio") val allocators = use("std/allocators")-val thread = use("std/thread")-val bytes = use("../core/bytes.sx")-val lists = use("../core/lists.sx")-val objid = use("../object/id.sx")-val types = use("../object/types.sx")-val names = use("../object/names.sx")-val blob = use("../object/blob.sx")-val tree = use("../object/tree.sx")-val commit = use("../object/commit.sx")-val view = use("../object/view.sx")-val store = use("../store/store.sx")-val layout = use("../store/layout.sx")-val state = use("../store/state.sx")-val files = use("../io/files.sx")-val native = use("../io/native.sx")+val thread = use("std/thread")+val bytes = use("../core/bytes.sx")+val lists = use("../core/lists.sx")+val objid = use("../object/id.sx")+val types = use("../object/types.sx")+val names = use("../object/names.sx")+val blob = use("../object/blob.sx")+val tree = use("../object/tree.sx")+val commit = use("../object/commit.sx")+val view = use("../object/view.sx")+val store = use("../store/store.sx")+val layout = use("../store/layout.sx")+val state = use("../store/state.sx")+val files = use("../io/files.sx")+val native = use("../io/native.sx") extern (C) fn openat(dirfd: i32, path: ref u8, flags: i32, mode: i32) i32 = "openat" extern (C) fn mkdirat(dirfd: i32, path: ref u8, mode: i32) i32 = "mkdirat"@@ -347,7 +347,11 @@ return success } -fn write_symlink(handles: list[ref store.Handle], t: CheckoutTarget, blob_id: objid.Id) bool = trust {+fn write_symlink(+ handles: list[ref store.Handle],+ t: CheckoutTarget,+ blob_id: objid.Id+) bool = trust { val body_opt = state.read_body(handles, blob_id, types.BLOB) val body: mut bytes.Bytes = bytes.empty() match body_opt {@@ -503,8 +507,8 @@ @append(walk.dirs, path) walk_tree(walk, e.target, path, depth + 1) } elif e.kind == tree.KIND_FILE- || e.kind == tree.KIND_EXECUTABLE- || e.kind == tree.KIND_SYMLINK {+ || e.kind == tree.KIND_EXECUTABLE+ || e.kind == tree.KIND_SYMLINK { add_task(walk, path, e.kind, e.target) } elif e.kind == tree.KIND_SUBMODULE { @append(walk.dirs, path)@@ -769,7 +773,10 @@ close(root_fd) if had_failure { if failed_path.len > 0 {- stdio.eprint("vn: checkout failed at: {s}\n", {str.view(failed_path.ptr, failed_path.len as i64)})+ stdio.eprint(+ "vn: checkout failed at: {s}\n",+ {str.view(failed_path.ptr, failed_path.len as i64)}+ ) } else { stdio.eprint("vn: checkout failed\n", {}) }