From 4b9fc524d79f48c52902166b96d80a6b3efec071 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Tue, 14 Apr 2026 07:15:25 +0000 Subject: 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. --- object/typ/type.go | 17 ----------------- object/typ/type_details.go | 16 ++++++---------- 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() -- cgit v1.3.1-10-gc9f91