Skip to content

Commit 1499c8f

Browse files
committed
Introduced sha256 support for git-sizer
1 parent b84ee4d commit 1499c8f

File tree

11 files changed

+154
-80
lines changed

11 files changed

+154
-80
lines changed

git/git.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ type Repository struct {
2424
// gitBin is the path of the `git` executable that should be used
2525
// when running commands in this repository.
2626
gitBin string
27+
// hashAgo is repository hash algo
28+
hashAlgo HashAlgo
2729
}
2830

2931
// smartJoin returns `relPath` if it is an absolute path. If not, it
@@ -49,9 +51,18 @@ func NewRepositoryFromGitDir(gitDir string) (*Repository, error) {
4951
)
5052
}
5153

54+
hashAlgo := HashSHA1
55+
cmd := exec.Command(gitBin, "--git-dir", gitDir, "rev-parse", "--show-object-format")
56+
if out, err := cmd.Output(); err == nil {
57+
if string(bytes.TrimSpace(out)) == "sha256" {
58+
hashAlgo = HashSHA256
59+
}
60+
}
61+
5262
repo := Repository{
53-
gitDir: gitDir,
54-
gitBin: gitBin,
63+
gitDir: gitDir,
64+
gitBin: gitBin,
65+
hashAlgo: hashAlgo,
5566
}
5667

5768
full, err := repo.IsFull()
@@ -170,3 +181,15 @@ func (repo *Repository) GitPath(relPath string) (string, error) {
170181
// current directory, we can use it as-is:
171182
return string(bytes.TrimSpace(out)), nil
172183
}
184+
185+
func (repo *Repository) HashAlgo() HashAlgo {
186+
return repo.hashAlgo
187+
}
188+
189+
func (repo *Repository) HashSize() int {
190+
return repo.hashAlgo.HashSize()
191+
}
192+
193+
func (repo *Repository) NullOID() OID {
194+
return repo.hashAlgo.NullOID()
195+
}

git/obj_iter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (repo *Repository) NewObjectIter(ctx context.Context) (*ObjectIter, error)
3030
errCh: make(chan error),
3131
headerCh: make(chan BatchHeader),
3232
}
33-
33+
hashHexSize := repo.HashSize() * 2
3434
iter.p.Add(
3535
// Read OIDs from `iter.oidCh` and write them to `git
3636
// rev-list`:
@@ -68,10 +68,10 @@ func (repo *Repository) NewObjectIter(ctx context.Context) (*ObjectIter, error)
6868
pipe.LinewiseFunction(
6969
"copy-oids",
7070
func(_ context.Context, _ pipe.Env, line []byte, stdout *bufio.Writer) error {
71-
if len(line) < 40 {
71+
if len(line) < hashHexSize {
7272
return fmt.Errorf("line too short: '%s'", line)
7373
}
74-
if _, err := stdout.Write(line[:40]); err != nil {
74+
if _, err := stdout.Write(line[:hashHexSize]); err != nil {
7575
return fmt.Errorf("writing OID to 'git cat-file': %w", err)
7676
}
7777
if err := stdout.WriteByte('\n'); err != nil {

git/obj_resolver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ func (repo *Repository) ResolveObject(name string) (OID, error) {
99
cmd := repo.GitCommand("rev-parse", "--verify", "--end-of-options", name)
1010
output, err := cmd.Output()
1111
if err != nil {
12-
return NullOID, fmt.Errorf("resolving object %q: %w", name, err)
12+
return repo.NullOID(), fmt.Errorf("resolving object %q: %w", name, err)
1313
}
1414
oidString := string(bytes.TrimSpace(output))
1515
oid, err := NewOID(oidString)
1616
if err != nil {
17-
return NullOID, fmt.Errorf("parsing output %q from 'rev-parse': %w", oidString, err)
17+
return repo.NullOID(), fmt.Errorf("parsing output %q from 'rev-parse': %w", oidString, err)
1818
}
1919
return oid, nil
2020
}

git/oid.go

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,75 @@
11
package git
22

33
import (
4+
"bytes"
5+
"crypto/sha1"
6+
"crypto/sha256"
47
"encoding/hex"
58
"errors"
69
)
710

11+
const (
12+
HashSizeSHA256 = sha256.Size
13+
HashSizeSHA1 = sha1.Size
14+
HashSizeMax = HashSizeSHA256
15+
)
16+
17+
type HashAlgo int
18+
19+
const (
20+
HashUnknown HashAlgo = iota
21+
HashSHA1
22+
HashSHA256
23+
)
24+
825
// OID represents the SHA-1 object ID of a Git object, in binary
926
// format.
1027
type OID struct {
11-
v [20]byte
28+
v [HashSizeMax]byte
29+
hashSize int
1230
}
1331

14-
// NullOID is the null object ID; i.e., all zeros.
15-
var NullOID OID
32+
func (h HashAlgo) NullOID() OID {
33+
switch h {
34+
case HashSHA1:
35+
return OID{hashSize: HashSizeSHA1}
36+
case HashSHA256:
37+
return OID{hashSize: HashSizeSHA256}
38+
}
39+
return OID{}
40+
}
41+
42+
func (h HashAlgo) HashSize() int {
43+
switch h {
44+
case HashSHA1:
45+
return HashSizeSHA1
46+
case HashSHA256:
47+
return HashSizeSHA256
48+
}
49+
return 0
50+
}
51+
52+
// defaultNullOID is the null object ID; i.e., all zeros.
53+
var defaultNullOID OID
54+
55+
func IsNullOID(o OID) bool {
56+
return bytes.Equal(o.v[:], defaultNullOID.v[:])
57+
}
1658

1759
// OIDFromBytes converts a byte slice containing an object ID in
1860
// binary format into an `OID`.
1961
func OIDFromBytes(oidBytes []byte) (OID, error) {
2062
var oid OID
21-
if len(oidBytes) != len(oid.v) {
63+
oidSize := len(oidBytes)
64+
if oidSize != HashSizeSHA1 && oidSize != HashSizeSHA256 {
2265
return OID{}, errors.New("bytes oid has the wrong length")
2366
}
24-
copy(oid.v[0:20], oidBytes)
67+
oid.hashSize = oidSize
68+
copy(oid.v[0:oidSize], oidBytes)
2569
return oid, nil
2670
}
2771

28-
// NewOID converts an object ID in hex format (i.e., `[0-9a-f]{40}`)
29-
// into an `OID`.
72+
// NewOID converts an object ID in hex format (i.e., `[0-9a-f]{40,64}`) into an `OID`.
3073
func NewOID(s string) (OID, error) {
3174
oidBytes, err := hex.DecodeString(s)
3275
if err != nil {
@@ -37,18 +80,18 @@ func NewOID(s string) (OID, error) {
3780

3881
// String formats `oid` as a string in hex format.
3982
func (oid OID) String() string {
40-
return hex.EncodeToString(oid.v[:])
83+
return hex.EncodeToString(oid.v[:oid.hashSize])
4184
}
4285

4386
// Bytes returns a byte slice view of `oid`, in binary format.
4487
func (oid OID) Bytes() []byte {
45-
return oid.v[:]
88+
return oid.v[:oid.hashSize]
4689
}
4790

4891
// MarshalJSON expresses `oid` as a JSON string with its enclosing
4992
// quotation marks.
5093
func (oid OID) MarshalJSON() ([]byte, error) {
51-
src := oid.v[:]
94+
src := oid.v[:oid.hashSize]
5295
dst := make([]byte, hex.EncodedLen(len(src))+2)
5396
dst[0] = '"'
5497
dst[len(dst)-1] = '"'

git/tree.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import (
1010

1111
// Tree represents a Git tree object.
1212
type Tree struct {
13-
data string
13+
data string
14+
hashSize int
1415
}
1516

1617
// ParseTree parses the tree object whose contents are contained in
1718
// `data`. `oid` is currently unused.
1819
func ParseTree(oid OID, data []byte) (*Tree, error) {
19-
return &Tree{string(data)}, nil
20+
return &Tree{string(data), oid.hashSize}, nil
2021
}
2122

2223
// Size returns the size of the tree object.
@@ -36,13 +37,15 @@ type TreeEntry struct {
3637
// TreeIter is an iterator over the entries in a Git tree object.
3738
type TreeIter struct {
3839
// The as-yet-unread part of the tree's data.
39-
data string
40+
data string
41+
hashSize int
4042
}
4143

4244
// Iter returns an iterator over the entries in `tree`.
4345
func (tree *Tree) Iter() *TreeIter {
4446
return &TreeIter{
45-
data: tree.data,
47+
data: tree.data,
48+
hashSize: tree.hashSize,
4649
}
4750
}
4851

@@ -74,12 +77,12 @@ func (iter *TreeIter) NextEntry() (TreeEntry, bool, error) {
7477
entry.Name = iter.data[:nulAt]
7578

7679
iter.data = iter.data[nulAt+1:]
77-
if len(iter.data) < 20 {
80+
if len(iter.data) < iter.hashSize {
7881
return TreeEntry{}, false, errors.New("tree entry ends unexpectedly")
7982
}
80-
81-
copy(entry.OID.v[0:20], iter.data[0:20])
82-
iter.data = iter.data[20:]
83+
entry.OID.hashSize = iter.hashSize
84+
copy(entry.OID.v[0:iter.hashSize], iter.data[0:iter.hashSize])
85+
iter.data = iter.data[iter.hashSize:]
8386

8487
return entry, true, nil
8588
}

git_sizer_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,3 +849,40 @@ func TestSubmodule(t *testing.T) {
849849
assert.Equal(t, counts.Count32(2), h.UniqueBlobCount, "unique blob count")
850850
assert.Equal(t, counts.Count32(3), h.MaxExpandedBlobCount, "max expanded blob count")
851851
}
852+
853+
func TestSHA256(t *testing.T) {
854+
t.Parallel()
855+
856+
ctx := context.Background()
857+
858+
t.Helper()
859+
860+
path, err := os.MkdirTemp("", "sha256")
861+
require.NoError(t, err)
862+
863+
testRepo := testutils.TestRepo{Path: path}
864+
defer testRepo.Remove(t)
865+
866+
// Don't use `GitCommand()` because the directory might not
867+
// exist yet:
868+
cmd := exec.Command("git", "init", "--object-format", "sha256", testRepo.Path)
869+
cmd.Env = testutils.CleanGitEnv()
870+
err = cmd.Run()
871+
require.NoError(t, err)
872+
873+
timestamp := time.Unix(1112911993, 0)
874+
875+
testRepo.AddFile(t, "hello.txt", "Hello, world!\n")
876+
cmd = testRepo.GitCommand(t, "commit", "-m", "initial")
877+
testutils.AddAuthorInfo(cmd, &timestamp)
878+
require.NoError(t, cmd.Run(), "creating initial commit")
879+
880+
cmd = testRepo.GitCommand(t, "commit", "-m", "initial", "--allow-empty")
881+
testutils.AddAuthorInfo(cmd, &timestamp)
882+
require.NoError(t, cmd.Run(), "creating commit")
883+
884+
repo := testRepo.Repository(t)
885+
886+
_, err = sizes.CollectReferences(ctx, repo, refGrouper{})
887+
require.NoError(t, err)
888+
}

go.mod

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
module github.com/github/git-sizer
22

3-
go 1.17
3+
go 1.23.0
4+
5+
toolchain go1.24.1
46

57
require (
6-
github.com/cli/safeexec v1.0.0
8+
github.com/cli/safeexec v1.0.1
79
github.com/davecgh/go-spew v1.1.1 // indirect
8-
github.com/spf13/pflag v1.0.5
9-
github.com/stretchr/testify v1.8.1
10-
golang.org/x/sync v0.1.0 // indirect
10+
github.com/spf13/pflag v1.0.6
11+
github.com/stretchr/testify v1.10.0
12+
golang.org/x/sync v0.12.0 // indirect
1113
)
1214

1315
require github.com/github/go-pipe v1.0.2

go.sum

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
github.com/cli/safeexec v1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI=
2-
github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q=
3-
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
4-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1+
github.com/cli/safeexec v1.0.1 h1:e/C79PbXF4yYTN/wauC4tviMxEV13BwljGj0N9j+N00=
2+
github.com/cli/safeexec v1.0.1/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q=
53
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
64
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
75
github.com/github/go-pipe v1.0.2 h1:befTXflsc6ir/h9f6Q7QCDmfojoBswD1MfQrPhmmSoA=
@@ -14,48 +12,16 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1412
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
1513
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1614
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
17-
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
18-
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
19-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
20-
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
21-
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
22-
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
23-
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
24-
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
25-
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
26-
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
15+
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
16+
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
17+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
18+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
2719
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
2820
go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
29-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
30-
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
31-
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
32-
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
33-
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
34-
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
35-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
36-
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
37-
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
38-
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
39-
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
40-
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
41-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
42-
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
43-
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
44-
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
45-
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
46-
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
47-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
48-
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
49-
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
50-
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
51-
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
52-
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
53-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
54-
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
55-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
21+
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
22+
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
5623
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
5724
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
5825
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
59-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
6026
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
6127
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/testutils/repoutils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func (repo *TestRepo) UpdateRef(t *testing.T, refname string, oid git.OID) {
165165

166166
var cmd *exec.Cmd
167167

168-
if oid == git.NullOID {
168+
if git.IsNullOID(oid) {
169169
cmd = repo.GitCommand(t, "update-ref", "-d", refname)
170170
} else {
171171
cmd = repo.GitCommand(t, "update-ref", refname, oid.String())

sizes/graph.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func ScanRepositoryUsingGraph(
134134
case "tree":
135135
trees = append(trees, ObjectHeader{obj.OID, obj.ObjectSize})
136136
case "commit":
137-
commits = append(commits, CommitHeader{ObjectHeader{obj.OID, obj.ObjectSize}, git.NullOID})
137+
commits = append(commits, CommitHeader{ObjectHeader{obj.OID, obj.ObjectSize}, repo.NullOID()})
138138
case "tag":
139139
tags = append(tags, ObjectHeader{obj.OID, obj.ObjectSize})
140140
default:

0 commit comments

Comments
 (0)