Skip to content

Commit 1da0bac

Browse files
committed
storage/filesystem: dotgit, Add prefix check to packfile name. Fixes src-d#1149
Signed-off-by: Yuichi Watanabe <[email protected]>
1 parent bcaede8 commit 1da0bac

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: storage/filesystem/dotgit/dotgit.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ const (
3333

3434
tmpPackedRefsPrefix = "._packed-refs"
3535

36-
packExt = ".pack"
37-
idxExt = ".idx"
36+
packPrefix = "pack-"
37+
packExt = ".pack"
38+
idxExt = ".idx"
3839
)
3940

4041
var (
@@ -224,11 +225,11 @@ func (d *DotGit) objectPacks() ([]plumbing.Hash, error) {
224225

225226
var packs []plumbing.Hash
226227
for _, f := range files {
227-
if !strings.HasSuffix(f.Name(), packExt) {
228+
n := f.Name()
229+
if !strings.HasPrefix(n, packPrefix) || !strings.HasSuffix(n, packExt) {
228230
continue
229231
}
230232

231-
n := f.Name()
232233
h := plumbing.NewHash(n[5 : len(n)-5]) //pack-(hash).pack
233234
if h.IsZero() {
234235
// Ignore files with badly-formatted names.

0 commit comments

Comments
 (0)