aboutsummaryrefslogtreecommitdiff
path: root/packfile/ingest/thin_unresolved.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-10 14:07:54 +0800
committerGravatar Runxi Yu2026-03-10 14:07:54 +0800
commitc2cb06aa23a1769a0d84756acccf1ac1358f61ef (patch)
tree86d991b67542dd8e8509a74c832b749ccf948342 /packfile/ingest/thin_unresolved.go
parentcommitgraph: Move out of format/ (diff)
signatureNo signature
*: format/pack -> packfile; format/delta -> delta; delete format
Diffstat (limited to 'packfile/ingest/thin_unresolved.go')
-rw-r--r--packfile/ingest/thin_unresolved.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/packfile/ingest/thin_unresolved.go b/packfile/ingest/thin_unresolved.go
new file mode 100644
index 00000000..347f3f29
--- /dev/null
+++ b/packfile/ingest/thin_unresolved.go
@@ -0,0 +1,34 @@
+package ingest
+
+import (
+ "bytes"
+ "slices"
+
+ "codeberg.org/lindenii/furgit/objectid"
+ "codeberg.org/lindenii/furgit/objecttype"
+)
+
+// unresolvedThinBaseIDs returns sorted unique unresolved ref base IDs.
+func unresolvedThinBaseIDs(state *ingestState) []objectid.ObjectID {
+ seen := make(map[objectid.ObjectID]struct{})
+
+ for _, idx := range state.unresolvedRefDeltas {
+ record := state.records[idx]
+ if record.packedType != objecttype.TypeRefDelta {
+ continue
+ }
+
+ seen[record.baseObject] = struct{}{}
+ }
+
+ out := make([]objectid.ObjectID, 0, len(seen))
+ for id := range seen {
+ out = append(out, id)
+ }
+
+ slices.SortFunc(out, func(a, b objectid.ObjectID) int {
+ return bytes.Compare(a.RawBytes(), b.RawBytes())
+ })
+
+ return out
+}