| ... | ... | @@ -770,7 +770,7 @@ pub const TreeDiff = struct { |
| 770 | 770 | }; |
| 771 | 771 | }; |
| 772 | 772 | |
| 773 | | pub fn getBranches(alloc: std.mem.Allocator, dir: nfs.Dir) ![]const Ref { |
| 773 | pub fn getBranches(alloc: std.mem.Allocator, dir: nfs.Dir) ![]Ref { |
| 774 | 774 | const t = tracer.trace(@src(), "", .{}); |
| 775 | 775 | defer t.end(); |
| 776 | 776 | |
| ... | ... | @@ -788,15 +788,14 @@ pub fn getBranches(alloc: std.mem.Allocator, dir: nfs.Dir) ![]const Ref { |
| 788 | 788 | while (iter.next()) |line| { |
| 789 | 789 | var jter = std.mem.splitScalar(u8, line, ' '); |
| 790 | 790 | try list.append(Ref{ |
| 791 | | .commit = ensureObjId(CommitId, jter.next().?), |
| 791 | .oid = ensureObjId(CommitId, jter.next().?).id, |
| 792 | 792 | .label = extras.trimPrefixEnsure(jter.rest(), "refs/heads/").?, |
| 793 | | .tag = null, |
| 794 | 793 | }); |
| 795 | 794 | } |
| 796 | 795 | return list.toOwnedSlice(); |
| 797 | 796 | } |
| 798 | 797 | |
| 799 | | pub fn getTags(alloc: std.mem.Allocator, dir: nfs.Dir) ![]const Ref { |
| 798 | pub fn getTags(alloc: std.mem.Allocator, dir: nfs.Dir) ![]Ref { |
| 800 | 799 | const t = tracer.trace(@src(), "", .{}); |
| 801 | 800 | defer t.end(); |
| 802 | 801 | |
| ... | ... | @@ -807,7 +806,7 @@ pub fn getTags(alloc: std.mem.Allocator, dir: nfs.Dir) ![]const Ref { |
| 807 | 806 | const result = try std.process.Child.run(.{ |
| 808 | 807 | .allocator = alloc, |
| 809 | 808 | .cwd_dir = dir.to_std(), |
| 810 | | .argv = &.{ "git", "show-ref", "--tags", "--dereference" }, |
| 809 | .argv = &.{ "git", "show-ref", "--tags" }, |
| 811 | 810 | .max_output_bytes = 1024 * 1024 * 1024, |
| 812 | 811 | }); |
| 813 | 812 | if (result.term == .Exited and result.term.Exited == 1) return &.{}; // show-ref exits 1 when there are no tags |
| ... | ... | @@ -820,43 +819,18 @@ pub fn getTags(alloc: std.mem.Allocator, dir: nfs.Dir) ![]const Ref { |
| 820 | 819 | var jter = std.mem.splitScalar(u8, line, ' '); |
| 821 | 820 | const id = ensureObjId(CommitId, jter.next().?).id; |
| 822 | 821 | const label = extras.trimPrefixEnsure(jter.rest(), "refs/tags/").?; |
| 823 | | extras.assertLog(!std.mem.endsWith(u8, label, "^{}"), "{s}", .{label}); |
| 824 | | |
| 825 | | switch (try getType(alloc, dir, id)) { |
| 826 | | .tree => continue, |
| 827 | | .blob => unreachable, |
| 828 | | .commit => { |
| 829 | | try list.append(Ref{ |
| 830 | | .label = label, |
| 831 | | .commit = ensureObjId(CommitId, id), |
| 832 | | .tag = null, |
| 833 | | }); |
| 834 | | }, |
| 835 | | .tag => { |
| 836 | | const derefline = iter.next().?; |
| 837 | | var kter = std.mem.splitScalar(u8, derefline, ' '); |
| 838 | | const id2 = ensureObjId(CommitId, kter.next().?).id; |
| 839 | | const label2 = extras.trimPrefixEnsure(kter.rest(), "refs/tags/").?; |
| 840 | | extras.assertLog(std.mem.endsWith(u8, label2, "^{}"), "{s}", .{label2}); |
| 841 | | std.debug.assert(std.mem.eql(u8, label, extras.trimSuffixEnsure(label2, "^{}").?)); |
| 842 | | // extras.assertLog(try isType(alloc, dir, id2, .commit), id2); // linux kernel has a single tag that points at a tree |
| 843 | | if (!try isType(alloc, dir, id2, .commit)) continue; |
| 844 | | |
| 845 | | try list.append(Ref{ |
| 846 | | .label = label, |
| 847 | | .commit = ensureObjId(CommitId, id2), |
| 848 | | .tag = ensureObjId(TagId, id), |
| 849 | | }); |
| 850 | | }, |
| 851 | | } |
| 822 | |
| 823 | try list.append(Ref{ |
| 824 | .oid = id, |
| 825 | .label = label, |
| 826 | }); |
| 852 | 827 | } |
| 853 | 828 | return list.toOwnedSlice(); |
| 854 | 829 | } |
| 855 | 830 | |
| 856 | 831 | pub const Ref = struct { |
| 832 | oid: Id, |
| 857 | 833 | label: string, |
| 858 | | commit: CommitId, |
| 859 | | tag: ?TagId, |
| 860 | 834 | }; |
| 861 | 835 | |
| 862 | 836 | // TODO make this inspect .git/objects |