aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem
diff options
context:
space:
mode:
authorYuichi Watanabe <yuichi.watanabe.ja@gmail.com>2019-05-17 14:13:34 +0900
committerYuichi Watanabe <yuichi.watanabe.ja@gmail.com>2019-05-17 14:13:34 +0900
commit1da0bac9d6e7142b46f1fb9ff007cbc90ca9af97 (patch)
tree057cb12d4e1a08c8034c2fd0f1f213151955ff2e /storage/filesystem
parentbcaede84719f0fd36b944a1b4f78e7ecc1ba10fe (diff)
downloadgo-git-1da0bac9d6e7142b46f1fb9ff007cbc90ca9af97.tar.gz
storage/filesystem: dotgit, Add prefix check to packfile name. Fixes #1149
Signed-off-by: Yuichi Watanabe <yuichi.watanabe.ja@gmail.com>
Diffstat (limited to 'storage/filesystem')
-rw-r--r--storage/filesystem/dotgit/dotgit.go9
1 files changed, 5 insertions, 4 deletions
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.