aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal/dotgit/dotgit.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-04-17 11:26:26 +0200
committerGitHub <noreply@github.com>2018-04-17 11:26:26 +0200
commiteec77c36c26558e470a3d882fb6c0d457f92891f (patch)
tree385728c45d7dd707c90dc9c3fd8efef06a37e4f0 /storage/filesystem/internal/dotgit/dotgit.go
parenta042efacfd3a278a9423008948022728555dcee1 (diff)
parent79db8cf8bf477c2bb9d01cbe289fbeaccaa1ee65 (diff)
downloadgo-git-eec77c36c26558e470a3d882fb6c0d457f92891f.tar.gz
Merge pull request #807 from keybase/strib/src-d-ignore-non-hash-files
dotgit: ignore filenames that don't match a hash
Diffstat (limited to 'storage/filesystem/internal/dotgit/dotgit.go')
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go
index 6f0f1a5..52b621c 100644
--- a/storage/filesystem/internal/dotgit/dotgit.go
+++ b/storage/filesystem/internal/dotgit/dotgit.go
@@ -162,8 +162,11 @@ func (d *DotGit) ObjectPacks() ([]plumbing.Hash, error) {
n := f.Name()
h := plumbing.NewHash(n[5 : len(n)-5]) //pack-(hash).pack
+ if h.IsZero() {
+ // Ignore files with badly-formatted names.
+ continue
+ }
packs = append(packs, h)
-
}
return packs, nil
@@ -255,7 +258,12 @@ func (d *DotGit) ForEachObjectHash(fun func(plumbing.Hash) error) error {
}
for _, o := range d {
- err = fun(plumbing.NewHash(base + o.Name()))
+ h := plumbing.NewHash(base + o.Name())
+ if h.IsZero() {
+ // Ignore files with badly-formatted names.
+ continue
+ }
+ err = fun(h)
if err != nil {
return err
}