Skip to content

Commit

Permalink
attest: Make sure trees are sorted. (#132)
Browse files Browse the repository at this point in the history
Git trees apparently need to be sorted by name.

Fixes error:

```
remote: error: object 7c8ce5a1d674a439b75abca064c24bfe1aaa6767: treeNotSorted: not properly sorted
remote: fatal: fsck error in packed object
error: remote unpack failed: index-pack abnormal exit
```

Signed-off-by: Billy Lynch <[email protected]>
  • Loading branch information
wlynch authored Sep 8, 2022
1 parent 06bc251 commit 2153fb9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/gitsign-attest/internal/attest/attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"log"
"os"
"path/filepath"
"sort"
"time"

"github.com/go-git/go-git/v5"
Expand Down Expand Up @@ -284,6 +285,10 @@ func appendTree(repo *git.Repository, treeSHA plumbing.Hash, new []object.TreeEn
for _, e := range files {
entries = append(entries, e)
}
// Git expects trees to be sorted by name.
sort.Slice(entries, func(i, j int) bool {
return entries[i].Name < entries[j].Name
})

return encode(repo.Storer, &object.Tree{
Entries: entries,
Expand Down

0 comments on commit 2153fb9

Please sign in to comment.