From 1da0bac9d6e7142b46f1fb9ff007cbc90ca9af97 Mon Sep 17 00:00:00 2001 From: Yuichi Watanabe Date: Fri, 17 May 2019 14:13:34 +0900 Subject: storage/filesystem: dotgit, Add prefix check to packfile name. Fixes #1149 Signed-off-by: Yuichi Watanabe --- storage/filesystem/dotgit/dotgit.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'storage/filesystem/dotgit/dotgit.go') diff --git a/storage/filesystem/dotgit/dotgit.go b/storage/filesystem/dotgit/dotgit.go index 111769b..d80d420 100644 --- a/storage/filesystem/dotgit/dotgit.go +++ b/storage/filesystem/dotgit/dotgit.go @@ -33,8 +33,9 @@ const ( tmpPackedRefsPrefix = "._packed-refs" - packExt = ".pack" - idxExt = ".idx" + packPrefix = "pack-" + packExt = ".pack" + idxExt = ".idx" ) var ( @@ -224,11 +225,11 @@ func (d *DotGit) objectPacks() ([]plumbing.Hash, error) { var packs []plumbing.Hash for _, f := range files { - if !strings.HasSuffix(f.Name(), packExt) { + n := f.Name() + if !strings.HasPrefix(n, packPrefix) || !strings.HasSuffix(n, packExt) { continue } - n := f.Name() h := plumbing.NewHash(n[5 : len(n)-5]) //pack-(hash).pack if h.IsZero() { // Ignore files with badly-formatted names. -- cgit