Skip to content

Commit 1d0a28b

Browse files
authored
Merge pull request #11 from nikola-sh/master
Search packs as Git does
2 parents b35104c + 1130661 commit 1d0a28b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pack/set.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var (
2727
// filepath that is a packfile.
2828
//
2929
// It includes one matchgroup, which is the SHA-1 name of the pack.
30-
nameRe = regexp.MustCompile(`^pack-([a-f0-9]{40}).pack$`)
30+
nameRe = regexp.MustCompile(`^(.*)\.pack$`)
3131
)
3232

3333
// NewSet creates a new *Set of all packfiles found in a given object database's
@@ -40,7 +40,7 @@ var (
4040
func NewSet(db string) (*Set, error) {
4141
pd := filepath.Join(db, "pack")
4242

43-
paths, err := filepath.Glob(filepath.Join(pd, "pack-*.pack"))
43+
paths, err := filepath.Glob(filepath.Join(pd, "*.pack"))
4444
if err != nil {
4545
return nil, err
4646
}
@@ -55,7 +55,7 @@ func NewSet(db string) (*Set, error) {
5555

5656
name := submatch[1]
5757

58-
idxf, err := os.Open(filepath.Join(pd, fmt.Sprintf("pack-%s.idx", name)))
58+
idxf, err := os.Open(filepath.Join(pd, fmt.Sprintf("%s.idx", name)))
5959
if err != nil {
6060
// We have a pack (since it matched the regex), but the
6161
// index is missing or unusable. Skip this pack and
@@ -69,7 +69,7 @@ func NewSet(db string) (*Set, error) {
6969
continue
7070
}
7171

72-
packf, err := os.Open(filepath.Join(pd, fmt.Sprintf("pack-%s.pack", name)))
72+
packf, err := os.Open(filepath.Join(pd, fmt.Sprintf("%s.pack", name)))
7373
if err != nil {
7474
return nil, err
7575
}

0 commit comments

Comments
 (0)