File: type.go

package info (click to toggle)
golang-github-git-lfs-gitobj 2.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 432 kB
  • sloc: makefile: 2; sh: 1
file content (58 lines) | stat: -rw-r--r-- 1,551 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package pack

import (
	"errors"
	"fmt"
)

// PackedObjectType is a constant type that is defined for all valid object
// types that a packed object can represent.
type PackedObjectType uint8

const (
	// TypeNone is the zero-value for PackedObjectType, and represents the
	// absence of a type.
	TypeNone PackedObjectType = iota
	// TypeCommit is the PackedObjectType for commit objects.
	TypeCommit
	// TypeTree is the PackedObjectType for tree objects.
	TypeTree
	// Typeblob is the PackedObjectType for blob objects.
	TypeBlob
	// TypeTag is the PackedObjectType for tag objects.
	TypeTag

	// TypeObjectOffsetDelta is the type for OBJ_OFS_DELTA-typed objects.
	TypeObjectOffsetDelta PackedObjectType = 6
	// TypeObjectReferenceDelta is the type for OBJ_REF_DELTA-typed objects.
	TypeObjectReferenceDelta PackedObjectType = 7
)

// String implements fmt.Stringer and returns an encoding of the type valid for
// use in the loose object format protocol (see: package 'gitobj' for more).
//
// If the receiving instance is not defined, String() will panic().
func (t PackedObjectType) String() string {
	switch t {
	case TypeNone:
		return "<none>"
	case TypeCommit:
		return "commit"
	case TypeTree:
		return "tree"
	case TypeBlob:
		return "blob"
	case TypeTag:
		return "tag"
	case TypeObjectOffsetDelta:
		return "obj_ofs_delta"
	case TypeObjectReferenceDelta:
		return "obj_ref_delta"
	}

	panic(fmt.Sprintf("gitobj/pack: unknown object type: %d", t))
}

var (
	errUnrecognizedObjectType = errors.New("gitobj/pack: unrecognized object type")
)