aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem
diff options
context:
space:
mode:
Diffstat (limited to 'storage/filesystem')
-rw-r--r--storage/filesystem/dotgit/dotgit.go9
-rw-r--r--storage/filesystem/dotgit/dotgit_test.go5
2 files changed, 10 insertions, 4 deletions
diff --git a/storage/filesystem/dotgit/dotgit.go b/storage/filesystem/dotgit/dotgit.go
index 111769b..7989e53 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.HasSuffix(n, packExt) || !strings.HasPrefix(n, packPrefix) {
continue
}
- n := f.Name()
h := plumbing.NewHash(n[5 : len(n)-5]) //pack-(hash).pack
if h.IsZero() {
// Ignore files with badly-formatted names.
diff --git a/storage/filesystem/dotgit/dotgit_test.go b/storage/filesystem/dotgit/dotgit_test.go
index 31c6fe0..bd4e9f0 100644
--- a/storage/filesystem/dotgit/dotgit_test.go
+++ b/storage/filesystem/dotgit/dotgit_test.go
@@ -464,6 +464,11 @@ func testObjectPacks(c *C, fs billy.Filesystem, dir *DotGit, f *fixtures.Fixture
c.Assert(err, IsNil)
err = badFile.Close()
c.Assert(err, IsNil)
+ // temporary file generated by git gc
+ tmpFile, err := fs.Create("objects/pack/.tmp-11111-pack-58rf8y4wm1b1k52bpe0kdlx6lpreg6ahso8n3ylc.pack")
+ c.Assert(err, IsNil)
+ err = tmpFile.Close()
+ c.Assert(err, IsNil)
hashes2, err := dir.ObjectPacks()
c.Assert(err, IsNil)