mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-13 00:56:25 -04:00
Fix empty tree hash for SHA-256 repos
This commit is contained in:
parent
38dd035e28
commit
4c43104537
|
|
@ -8,8 +8,9 @@ import (
|
|||
"github.com/stefanhaller/git-todo-parser/todo"
|
||||
)
|
||||
|
||||
// Special commit hash for empty tree object
|
||||
// Empty tree object hashes for SHA-1 and SHA-256 repos.
|
||||
const EmptyTreeCommitHash = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
|
||||
const EmptyTreeCommitHashSHA256 = "6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321"
|
||||
|
||||
type CommitStatus uint8
|
||||
|
||||
|
|
@ -122,11 +123,20 @@ func (c *Commit) ShortRefName() string {
|
|||
|
||||
func (c *Commit) ParentRefName() string {
|
||||
if c.IsFirstCommit() {
|
||||
return EmptyTreeCommitHash
|
||||
return c.emptyTreeHash()
|
||||
}
|
||||
return c.RefName() + "^"
|
||||
}
|
||||
|
||||
// emptyTreeHash returns the empty tree object hash matching this repo's
|
||||
// object format. SHA-256 repos produce 64-char hashes; SHA-1 repos 40-char.
|
||||
func (c *Commit) emptyTreeHash() string {
|
||||
if len(c.Hash()) > 40 {
|
||||
return EmptyTreeCommitHashSHA256
|
||||
}
|
||||
return EmptyTreeCommitHash
|
||||
}
|
||||
|
||||
func (c *Commit) Parents() []string {
|
||||
return lo.Map(c.parents, func(s *string, _ int) string { return *s })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,11 @@ func getNextPipes(prevPipes []Pipe, commit *models.Commit, getStyle func(c *mode
|
|||
|
||||
var toHash *string
|
||||
if commit.IsFirstCommit() {
|
||||
toHash = &EmptyTreeCommitHash
|
||||
emptyHash := EmptyTreeCommitHash
|
||||
if len(commit.Hash()) > 40 {
|
||||
emptyHash = models.EmptyTreeCommitHashSHA256
|
||||
}
|
||||
toHash = &emptyHash
|
||||
} else {
|
||||
toHash = commit.ParentPtrs()[0]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue