Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

could not get blob from packfiles #1153

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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