mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 10:12:06 +03:00
repository: workaround a go-git bug and ensure sorted tree object
This commit is contained in:
parent
064a96f808
commit
ca4020f4fa
@ -8,6 +8,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
stdpath "path"
|
stdpath "path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -359,7 +360,22 @@ func (repo *GoGitRepo) ReadData(hash Hash) ([]byte, error) {
|
|||||||
func (repo *GoGitRepo) StoreTree(mapping []TreeEntry) (Hash, error) {
|
func (repo *GoGitRepo) StoreTree(mapping []TreeEntry) (Hash, error) {
|
||||||
var tree object.Tree
|
var tree object.Tree
|
||||||
|
|
||||||
for _, entry := range mapping {
|
// TODO: can be removed once https://github.com/go-git/go-git/issues/193 is resolved
|
||||||
|
sorted := make([]TreeEntry, len(mapping))
|
||||||
|
copy(sorted, mapping)
|
||||||
|
sort.Slice(sorted, func(i, j int) bool {
|
||||||
|
nameI := sorted[i].Name
|
||||||
|
if sorted[i].ObjectType == Tree {
|
||||||
|
nameI += "/"
|
||||||
|
}
|
||||||
|
nameJ := sorted[j].Name
|
||||||
|
if sorted[j].ObjectType == Tree {
|
||||||
|
nameJ += "/"
|
||||||
|
}
|
||||||
|
return nameI < nameJ
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, entry := range sorted {
|
||||||
mode := filemode.Regular
|
mode := filemode.Regular
|
||||||
if entry.ObjectType == Tree {
|
if entry.ObjectType == Tree {
|
||||||
mode = filemode.Dir
|
mode = filemode.Dir
|
||||||
|
Loading…
Reference in New Issue
Block a user