Skip to content

Commit

Permalink
Merge pull request #1 from nulab/patch-1149
Browse files Browse the repository at this point in the history
Patch 1149
  • Loading branch information
vvatanabe authored May 17, 2019
2 parents 24de5ef + 5132088 commit 1114a49
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 5 additions & 4 deletions storage/filesystem/dotgit/dotgit.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ const (

tmpPackedRefsPrefix = "._packed-refs"

packExt = ".pack"
idxExt = ".idx"
packPrefix = "pack-"
packExt = ".pack"
idxExt = ".idx"
)

var (
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions storage/filesystem/dotgit/dotgit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,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)
Expand Down

0 comments on commit 1114a49

Please sign in to comment.