diff options
| author | 2026-06-07 06:14:54 +0000 | |
|---|---|---|
| committer | 2026-06-07 06:14:54 +0000 | |
| commit | ffb98db8fbcdae9332392aabb2bdd217795c0432 (patch) | |
| tree | 98592d6cd8c48229bd8f5745976f24a2210baa4b | |
| parent | *: Refactor file granularity (diff) | |
| signature | No signature | |
More cleanups
| -rw-r--r-- | config/config.go | 1 | ||||
| -rw-r--r-- | config/doc.go | 3 | ||||
| -rw-r--r-- | config/lookup.go | 24 | ||||
| -rw-r--r-- | object/commit/parse.go | 2 | ||||
| -rw-r--r-- | object/header/parse.go | 1 | ||||
| -rw-r--r-- | object/signature/parse.go | 2 | ||||
| -rw-r--r-- | object/store/reader.go | 9 | ||||
| -rw-r--r-- | object/typ/errors.go | 1 |
8 files changed, 23 insertions, 20 deletions
diff --git a/config/config.go b/config/config.go index 35e0ea09..523edaf8 100644 --- a/config/config.go +++ b/config/config.go @@ -1,4 +1,3 @@ -// Package config provides configuration parsing. package config import ( diff --git a/config/doc.go b/config/doc.go new file mode 100644 index 00000000..c2116c36 --- /dev/null +++ b/config/doc.go @@ -0,0 +1,3 @@ +// Package config parses Git configuration files +// and provides typed lookup of their values. +package config diff --git a/config/lookup.go b/config/lookup.go index ede2026e..33c72ac7 100644 --- a/config/lookup.go +++ b/config/lookup.go @@ -11,10 +11,10 @@ type LookupResult struct { } // String returns the explicit string value. -func (r LookupResult) String() (string, error) { - switch r.Kind { +func (result LookupResult) String() (string, error) { + switch result.Kind { case KindString: - return r.Value, nil + return result.Value, nil case KindValueless: return "", ErrValueless case KindMissing: @@ -25,10 +25,10 @@ func (r LookupResult) String() (string, error) { } // Bool interprets this lookup result using Git config boolean rules. -func (r LookupResult) Bool() (bool, error) { - switch r.Kind { +func (result LookupResult) Bool() (bool, error) { + switch result.Kind { case KindString: - return parseBool(r.Value) + return parseBool(result.Value) case KindValueless: return true, nil case KindMissing: @@ -39,10 +39,10 @@ func (r LookupResult) Bool() (bool, error) { } // Int interprets this lookup result as a Git integer value. -func (r LookupResult) Int() (int, error) { - switch r.Kind { +func (result LookupResult) Int() (int, error) { + switch result.Kind { case KindString: - return parseInt(r.Value) + return parseInt(result.Value) case KindValueless: return 0, ErrValueless case KindMissing: @@ -53,10 +53,10 @@ func (r LookupResult) Int() (int, error) { } // Int64 interprets this lookup result as a Git int64 value. -func (r LookupResult) Int64() (int64, error) { - switch r.Kind { +func (result LookupResult) Int64() (int64, error) { + switch result.Kind { case KindString: - return parseInt64(r.Value) + return parseInt64(result.Value) case KindValueless: return 0, ErrValueless case KindMissing: diff --git a/object/commit/parse.go b/object/commit/parse.go index 1e99ec48..f58b39ec 100644 --- a/object/commit/parse.go +++ b/object/commit/parse.go @@ -9,7 +9,7 @@ import ( "lindenii.org/go/furgit/object/signature" ) -// ErrInvalidCommit indicates an attempt to parse an invalid commit. +// ErrInvalidCommit indicates a malformed commit object. var ErrInvalidCommit = errors.New("object/commit: invalid commit") // Parse decodes a commit object body. diff --git a/object/header/parse.go b/object/header/parse.go index 0958c0dd..5829a755 100644 --- a/object/header/parse.go +++ b/object/header/parse.go @@ -9,6 +9,7 @@ import ( "lindenii.org/go/furgit/object/typ" ) +// ErrInvalidHeader indicates a malformed loose-object header. var ErrInvalidHeader = errors.New("object/header: invalid header") // Parse parses a canonical loose-object header ("type size\x00"). diff --git a/object/signature/parse.go b/object/signature/parse.go index f8c1666e..f792e27e 100644 --- a/object/signature/parse.go +++ b/object/signature/parse.go @@ -9,7 +9,7 @@ import ( "lindenii.org/go/lgo/intconv" ) -// ErrInvalidSignature indicates an attempt to parse an invalid signature. +// ErrInvalidSignature indicates a malformed signature. var ErrInvalidSignature = errors.New("object/signature: invalid signature") // Parse parses a canonical Git signature line. diff --git a/object/store/reader.go b/object/store/reader.go index 5fc76979..e8829b87 100644 --- a/object/store/reader.go +++ b/object/store/reader.go @@ -59,11 +59,10 @@ type ObjectReader interface { Refresh() error } -// ErrObjectNotFound indicates that -// an object does not exist in a backend. -// This error must only be produced by object stores, -// when it has no specified object ID, -// but no other unexpected conditions were encountered. +// ErrObjectNotFound indicates that an object does not exist in a backend. +// It must only be produced by an object store +// when the store does not contain the requested object ID +// and no other unexpected conditions were encountered. var ErrObjectNotFound = errors.New("object/store: object not found") // This is a sentinel with no details, diff --git a/object/typ/errors.go b/object/typ/errors.go index f5880e12..db132178 100644 --- a/object/typ/errors.go +++ b/object/typ/errors.go @@ -2,4 +2,5 @@ package typ import "errors" +// ErrInvalidType indicates an unknown or unsupported Git object type. var ErrInvalidType = errors.New("object/typ: invalid type") |
