diff options
| author | 2026-03-06 11:54:21 +0800 | |
|---|---|---|
| committer | 2026-03-06 11:55:56 +0800 | |
| commit | c62c5544fa23378843a3383a9dcd4494e5ea33bc (patch) | |
| tree | 8b825a36767fe0ba3fb44f27cb634047c4c0318f /format/commitgraph/parents.go | |
| parent | format/pack/ingest: Fix delta apply import (diff) | |
| signature | No signature | |
format/commitgraph: Split into ./read and ./ v0.1.60
Diffstat (limited to 'format/commitgraph/parents.go')
| -rw-r--r-- | format/commitgraph/parents.go | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/format/commitgraph/parents.go b/format/commitgraph/parents.go deleted file mode 100644 index df6d33ff..00000000 --- a/format/commitgraph/parents.go +++ /dev/null @@ -1,65 +0,0 @@ -package commitgraph - -// ParentRef references one parent position. -type ParentRef struct { - Valid bool - Pos Position -} - -func (reader *Reader) decodeParents(layer *layer, p1, p2 uint32) (ParentRef, ParentRef, []Position, error) { - parent1, err := reader.decodeSingleParent(p1) - if err != nil { - return ParentRef{}, ParentRef{}, nil, err - } - - if p2 == parentNone { - return parent1, ParentRef{}, nil, nil - } - - if p2&parentExtraMask == 0 { - parent2, err := reader.decodeSingleParent(p2) - if err != nil { - return ParentRef{}, ParentRef{}, nil, err - } - - return parent1, parent2, nil, nil - } - - edgeStart := p2 & parentLastMask - - parents, err := reader.decodeExtraEdgeList(layer, edgeStart) - if err != nil { - return ParentRef{}, ParentRef{}, nil, err - } - - if len(parents) == 0 { - return ParentRef{}, ParentRef{}, nil, &ErrMalformed{Path: layer.path, Reason: "empty EDGE list"} - } - - parent2 := ParentRef{Valid: true, Pos: parents[0]} - if len(parents) == 1 { - return parent1, parent2, nil, nil - } - - return parent1, parent2, parents[1:], nil -} - -func (reader *Reader) decodeSingleParent(raw uint32) (ParentRef, error) { - if raw == parentNone { - return ParentRef{}, nil - } - - if raw&parentExtraMask != 0 { - return ParentRef{}, &ErrMalformed{ - Path: "commit-graph", - Reason: "unexpected EDGE marker in single-parent slot", - } - } - - pos, err := reader.globalToPosition(raw) - if err != nil { - return ParentRef{}, err - } - - return ParentRef{Valid: true, Pos: pos}, nil -} |
