diff options
| author | 2026-04-14 07:15:25 +0000 | |
|---|---|---|
| committer | 2026-04-14 12:50:23 +0000 | |
| commit | 4b9fc524d79f48c52902166b96d80a6b3efec071 (patch) | |
| tree | d2e85bd44a5f42faecd4488c05b62a94fcb903a8 | |
| parent | object/signature: Rename Serialize to Bytes (diff) | |
| signature | No signature | |
object/typ: Don't mirror packfiles
Future, ref delta, and offset delta are all implementation details to
the packfile format and may or may not apply elsewhere. object/typ
should only include base object types and should be backend-agnostic
(and TypeInvalid).
Also, object type to property mappings such as isBase should generally
belong in the layer that actually needs them; in this case,
.pack/.idx/.rev.
| -rw-r--r-- | object/typ/type.go | 17 | ||||
| -rw-r--r-- | object/typ/type_details.go | 16 | ||||
| -rw-r--r-- | object/typ/type_ops.go | 8 |
3 files changed, 6 insertions, 35 deletions
diff --git a/object/typ/type.go b/object/typ/type.go index 69a07de3..5f7decc1 100644 --- a/object/typ/type.go +++ b/object/typ/type.go @@ -1,10 +1,6 @@ package typ // Type represents a Git object type. -// -// The values currently mirror what's found in the Git packfile format. -// -// TODO: Revisit this. type Type uint8 const ( @@ -22,17 +18,4 @@ const ( // TypeTag represents a Git tag. TypeTag Type = 4 - - // TypeFuture is reserved for the future, just like in the packfile format. - TypeFuture Type = 5 - - // TypeOfsDelta is reserved for internal use in packfile handlers. - // - // TODO: Revisit this. - TypeOfsDelta Type = 6 - - // TypeRefDelta is reserved for internal use in packfile handlers. - // - // TODO: Revisit this. - TypeRefDelta Type = 7 ) diff --git a/object/typ/type_details.go b/object/typ/type_details.go index 48dcf829..ebe1bbbe 100644 --- a/object/typ/type_details.go +++ b/object/typ/type_details.go @@ -1,8 +1,7 @@ package typ type typeDetails struct { - name string - isBaseObject bool + name string } func (ty Type) details() typeDetails { @@ -11,14 +10,11 @@ func (ty Type) details() typeDetails { //nolint:gochecknoglobals var typeTable = [...]typeDetails{ - TypeInvalid: {name: "", isBaseObject: false}, - TypeCommit: {name: "commit", isBaseObject: true}, - TypeTree: {name: "tree", isBaseObject: true}, - TypeBlob: {name: "blob", isBaseObject: true}, - TypeTag: {name: "tag", isBaseObject: true}, - TypeFuture: {name: "", isBaseObject: false}, - TypeOfsDelta: {name: "", isBaseObject: false}, - TypeRefDelta: {name: "", isBaseObject: false}, + TypeInvalid: {name: ""}, + TypeCommit: {name: "commit"}, + TypeTree: {name: "tree"}, + TypeBlob: {name: "blob"}, + TypeTag: {name: "tag"}, } //nolint:gochecknoglobals diff --git a/object/typ/type_ops.go b/object/typ/type_ops.go index 82e68147..535c7296 100644 --- a/object/typ/type_ops.go +++ b/object/typ/type_ops.go @@ -1,13 +1,5 @@ package typ -// IsBaseObject reports whether ty is -// one of the four ordinary Git object types. -// -// TODO: This should probably be removed. -func (ty Type) IsBaseObject() bool { - return ty.details().isBaseObject -} - // Name returns the canonical Git object type name. func (ty Type) Name() (string, bool) { details := ty.details() |
