Skip to content

Commit 67aa047

Browse files
committed
pack: add a hash member to pack structures
Let's add a hash member to the Packfile, V1, and V2 structures so that we can keep track of the hash algorithm in use when parsing these files.
1 parent 80e88dd commit 67aa047

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

pack/index_v1.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ package pack
22

33
import (
44
"encoding/binary"
5+
"hash"
56
)
67

78
// V1 implements IndexVersion for v1 packfiles.
8-
type V1 struct{}
9+
type V1 struct {
10+
hash hash.Hash
11+
}
912

1013
// Name implements IndexVersion.Name by returning the 20 byte SHA-1 object name
1114
// for the given entry at offset "at" in the v1 index file "idx".

pack/index_v2.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ package pack
22

33
import (
44
"encoding/binary"
5+
"hash"
56
)
67

78
// V2 implements IndexVersion for v2 packfiles.
8-
type V2 struct{}
9+
type V2 struct {
10+
hash hash.Hash
11+
}
912

1013
// Name implements IndexVersion.Name by returning the 20 byte SHA-1 object name
1114
// for the given entry at offset "at" in the v2 index file "idx".

pack/packfile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package pack
33
import (
44
"compress/zlib"
55
"fmt"
6+
"hash"
67
"io"
78
"io/ioutil"
89
)
@@ -18,6 +19,9 @@ type Packfile struct {
1819
// objects in this packfile.
1920
idx *Index
2021

22+
// hash is the hash algorithm used in this pack.
23+
hash hash.Hash
24+
2125
// r is an io.ReaderAt that allows read access to the packfile itself.
2226
r io.ReaderAt
2327
}

0 commit comments

Comments
 (0)