Documentation
¶
Index ¶
- func CanonicalEncode(s string) string
- func Compare(a, b string) int
- func FossilDecode(s string) string
- func FossilEncode(s string) string
- func HasValidZ(data []byte) bool
- func IsReservedName(name string) bool
- func LeafCard(f FileCard) string
- func MarshalInterior(refs []SubmanifestCard) []byte
- func MarshalLeaf(files []FileCard) []byte
- func StrictPathname(z string) bool
- func StripClearsign(data []byte) []byte
- func User(s string) *string
- func VerifyZ(data []byte) error
- func WorktreePathname(z string) bool
- type ArtifactType
- type AttachmentCard
- type CherryPick
- type Deck
- type EventCard
- type FileCard
- type SubmanifestCard
- type TagCard
- type TagType
- type TicketField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalEncode ¶ added in v0.14.0
CanonicalEncode is the minimal escaping draft-fossil-submanifests-00 §6.2 fixes for every filename a tree construction emits -- S card filenames and a leaf's F card filename and old-name tokens: exactly space, newline and backslash are escaped; every other byte, the decoder's other escape bytes included, is written raw. FossilDecode reverses it. A flat manifest keeps FossilEncode, so no artifact written before trees existed changes name.
func Compare ¶
Compare is the canonical comparator of draft-fossil-artifact-format-00 §4.5.3: a raw-byte comparison in which octets are compared as unsigned values, locale-independent, with no Unicode normalization and no case folding. A shorter string sorts before any extension of itself, an absent value (the empty string) sorts before any present value, and the directory separator '/' (0x2F) receives no special treatment. It returns a negative number, zero, or a positive number as a sorts before, equal to, or after b.
§4.5.3 defines one comparator shared by the F, J, M and T sort checks, the delta-baseline merge walk (§8.2) and single-name search (§8.4). A second copy anywhere is a correctness hazard, not a style issue: F ordering is what the baseline binary search and the delta-manifest merge walk will rely on, so two comparators that disagree resolve a delta manifest wrongly rather than merely failing validation. Route every such comparison through here.
func FossilDecode ¶
FossilDecode reverses FossilEncode, per §4.3. It mirrors canonical fossil's defossilize(): each recognized escape maps back to its raw byte, and an unrecognized escape drops the backslash and keeps the following byte literally. A lone trailing backslash (which a conforming encoder never emits) is left as-is rather than consuming a nonexistent following byte.
func FossilEncode ¶
FossilEncode escapes a string for use as an artifact/sync card field value, per §4.3 of the format spec. It mirrors canonical fossil's fossilize(): the eight bytes newline, space, tab, carriage return, vertical tab, form feed, NUL and backslash are each written as a two-character backslash escape; all other bytes pass through unchanged.
func HasValidZ ¶ added in v0.14.0
HasValidZ reports whether data, clearsign-stripped, ends in a Z card whose checksum verifies. Every artifact type requires a Z card (§5.2), so data without one can never parse as a deck; this costs one MD5 pass and no card allocation.
func IsReservedName ¶ added in v0.13.0
IsReservedName reports whether name is one of fossil's reserved repository filenames, matching file_is_reserved_name (src/file.c): _FOSSIL_ or .fslckout, in either case, optionally with a -wal, -shm or -journal suffix, either at the root or as the last component of a path. §4.6.3: such an F-card is silently dropped from a manifest after the sort-order check, not rejected.
func LeafCard ¶ added in v0.14.0
LeafCard is the F card line a leaf sub-manifest carries for f, its terminating newline included: what the cost of §6.3 measures a leaf by.
func MarshalInterior ¶ added in v0.14.0
func MarshalInterior(refs []SubmanifestCard) []byte
MarshalInterior serializes an interior sub-manifest (§6.2 step 3): one S card per member, in key order, and a Z card.
func MarshalLeaf ¶ added in v0.14.0
MarshalLeaf serializes a leaf sub-manifest (draft-fossil-submanifests-00 §6.2 step 2): files, in canonical filename order, as F cards and a Z card. Every file must carry a hash, since a sub-manifest holds no delete marker (§4.4).
func StrictPathname ¶ added in v0.12.0
StrictPathname reports whether z is a simple pathname as fossil's file_is_simple_pathname(z, 1) decides it (src/file.c), the rule a uvfile NAME must meet: a simple pathname with no backslash, in strict UTF-8 with no character above U+FFFF, no private-use character (U+E000..U+F8FF), no noncharacter (U+FDD0..U+FDEF, U+FFFE, U+FFFF) and no surrogate.
func StripClearsign ¶ added in v0.16.0
StripClearsign returns the inner control-artifact content of a clearsigned blob -- the bytes between the armor header's blank-line separator and the trailing signature block -- which is what the Z card is computed over and what the card parser consumes. It mirrors fossil's remove_pgp_signature (src/manifest.c): a byte-for-byte identity on non-clearsigned input (the overwhelmingly common case) and idempotent, since stripped content no longer begins with a header marker. The artifact's content-addressed hash is taken over the raw blob elsewhere, so this stripping never changes which UUID an artifact resolves to.
func User ¶
User returns a pointer to s for constructing Deck.U. Go forbids taking the address of a string literal directly, so composite literals go through this instead of Deck{U: &s}. Deliberately *string rather than a named struct type: passing *string straight to database/sql lets a nil argument bind SQL NULL and a non-nil one deref to its value automatically (see Deck.U), so crosslink/rebuild call sites need no special-casing.
func VerifyZ ¶
VerifyZ validates a control artifact's trailing Z-card checksum. The blob may arrive PGP/SSH clearsigned (historical artifacts, e.g. Fossil's own 2007-era check-ins); StripClearsign isolates the inner content the Z card is computed over so the last-35-byte check lands on the Z card and not on a trailing signature block. The artifact's content-addressed hash is computed over the raw blob elsewhere and is unaffected by this stripping.
func WorktreePathname ¶ added in v0.14.0
WorktreePathname reports whether z may name a file of a checkout: a simple pathname with no backslash, in valid UTF-8, the rule a writer applies to an F-card name. Sparse cones validate members with it (draft-fossil-sparse-cone-00 §3.2).
Types ¶
type ArtifactType ¶
type ArtifactType int
const ( Checkin ArtifactType = iota Wiki Ticket Event Cluster ForumPost Attachment Control // Submanifest is draft-fossil-submanifests-00's type 9: a slice of a // check-in's file set, as F cards (a leaf) or S cards (an interior node). // No card assigns it; Parse reassigns a D-less manifest to it (§4.3). Submanifest )
type AttachmentCard ¶
type CherryPick ¶
type Deck ¶
type Deck struct {
Type ArtifactType
A *AttachmentCard
B string
C string
D time.Time
E *EventCard
F []FileCard
G string
H string
I string
J []TicketField
K string
L string
M []string
N string
P []string
Q []CherryPick
R string
// S is a tree manifest's or an interior sub-manifest's references, in
// strictly ascending order of decoded filename
// (draft-fossil-submanifests-00 §3.6).
S []SubmanifestCard
T []TagCard
// U tracks the check-in user with three distinct states, mirroring
// fossil's src/manifest.c:1008-1016 U-card handling:
// - nil: no U-card in the manifest at all (SQL NULL at crosslink time)
// - non-nil, "anonymous": U-card present but empty (resolved at parse
// time, matching canonical fossil's own substitution)
// - non-nil, non-empty: U-card present with a login name
// Deliberately *string rather than string: a bare "" cannot represent
// "absent" and "present-but-empty" at once, which previously collapsed
// both into the same stored value. See User for constructing literals.
U *string
W []byte
Z string
// contains filtered or unexported fields
}
func Parse ¶
Parse reads an artifact as a pipeline of stages: frame the raw blob (§4.1 framing, wrapper strip, §4.1.1 first card, §6.2 Z checksum), scan the cards (§4.2), then determine the type (§5.3). Each stage is a helper so Parse reads as the pipeline and no stage runs before the one it depends on.
type SubmanifestCard ¶ added in v0.14.0
SubmanifestCard is one S card: the decoded least filename of the slice the referenced sub-manifest carries, and that sub-manifest's raw hash.