mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-19 21:28:28 +02:00
perf: improve loading speed of commits and reflog when log.showSignature=true
This commit is contained in:
parent
8c04118bb1
commit
f789e21377
@ -89,14 +89,12 @@ func (self *CommitLoader) GetCommits(opts GetCommitsOptions) ([]*models.Commit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = self.getLogCmd(opts).RunAndProcessLines(func(line string) (bool, error) {
|
err = self.getLogCmd(opts).RunAndProcessLines(func(line string) (bool, error) {
|
||||||
if canExtractCommit(line) {
|
commit := self.extractCommitFromLine(line)
|
||||||
commit := self.extractCommitFromLine(line)
|
if commit.Sha == firstPushedCommit {
|
||||||
if commit.Sha == firstPushedCommit {
|
passedFirstPushedCommit = true
|
||||||
passedFirstPushedCommit = true
|
|
||||||
}
|
|
||||||
commit.Status = map[bool]string{true: "unpushed", false: "pushed"}[!passedFirstPushedCommit]
|
|
||||||
commits = append(commits, commit)
|
|
||||||
}
|
}
|
||||||
|
commit.Status = map[bool]string{true: "unpushed", false: "pushed"}[!passedFirstPushedCommit]
|
||||||
|
commits = append(commits, commit)
|
||||||
return false, nil
|
return false, nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -435,7 +433,7 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
|
|||||||
|
|
||||||
return self.cmd.New(
|
return self.cmd.New(
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"git log %s %s %s --oneline %s%s --abbrev=%d%s",
|
"git -c log.showSignature=false log %s %s %s --oneline %s%s --abbrev=%d%s",
|
||||||
self.cmd.Quote(opts.RefName),
|
self.cmd.Quote(opts.RefName),
|
||||||
orderFlag,
|
orderFlag,
|
||||||
allFlag,
|
allFlag,
|
||||||
|
@ -40,7 +40,7 @@ func TestGetCommits(t *testing.T) {
|
|||||||
opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
|
opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
|
Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
|
||||||
Expect(`git log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, "", nil),
|
Expect(`git -c log.showSignature=false log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, "", nil),
|
||||||
|
|
||||||
expectedCommits: []*models.Commit{},
|
expectedCommits: []*models.Commit{},
|
||||||
expectedError: nil,
|
expectedError: nil,
|
||||||
@ -54,7 +54,7 @@ func TestGetCommits(t *testing.T) {
|
|||||||
// here it's seeing which commits are yet to be pushed
|
// here it's seeing which commits are yet to be pushed
|
||||||
Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
|
Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
|
||||||
// here it's actually getting all the commits in a formatted form, one per line
|
// here it's actually getting all the commits in a formatted form, one per line
|
||||||
Expect(`git log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, commitsOutput, nil).
|
Expect(`git -c log.showSignature=false log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, commitsOutput, nil).
|
||||||
// here it's seeing where our branch diverged from the master branch so that we can mark that commit and parent commits as 'merged'
|
// here it's seeing where our branch diverged from the master branch so that we can mark that commit and parent commits as 'merged'
|
||||||
Expect(`git merge-base "HEAD" "master"`, "26c07b1ab33860a1a7591a0638f9925ccf497ffa", nil),
|
Expect(`git merge-base "HEAD" "master"`, "26c07b1ab33860a1a7591a0638f9925ccf497ffa", nil),
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ func (self *ReflogCommitLoader) GetReflogCommits(lastReflogCommit *models.Commit
|
|||||||
filterPathArg = fmt.Sprintf(" --follow -- %s", self.cmd.Quote(filterPath))
|
filterPathArg = fmt.Sprintf(" --follow -- %s", self.cmd.Quote(filterPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdObj := self.cmd.New(fmt.Sprintf(`git log -g --abbrev=40 --format="%s"%s`, "%h%x00%ct%x00%gs%x00%p", filterPathArg)).DontLog()
|
cmdObj := self.cmd.New(fmt.Sprintf(`git -c log.showSignature=false log -g --abbrev=40 --format="%s"%s`, "%h%x00%ct%x00%gs%x00%p", filterPathArg)).DontLog()
|
||||||
onlyObtainedNewReflogCommits := false
|
onlyObtainedNewReflogCommits := false
|
||||||
err := cmdObj.RunAndProcessLines(func(line string) (bool, error) {
|
err := cmdObj.RunAndProcessLines(func(line string) (bool, error) {
|
||||||
fields := strings.SplitN(line, "\x00", 4)
|
fields := strings.SplitN(line, "\x00", 4)
|
||||||
|
@ -34,7 +34,7 @@ func TestGetReflogCommits(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "no reflog entries",
|
testName: "no reflog entries",
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git log -g --abbrev=40 --format="%h%x00%ct%x00%gs%x00%p"`, "", nil),
|
Expect(`git -c log.showSignature=false log -g --abbrev=40 --format="%h%x00%ct%x00%gs%x00%p"`, "", nil),
|
||||||
|
|
||||||
lastReflogCommit: nil,
|
lastReflogCommit: nil,
|
||||||
expectedCommits: []*models.Commit{},
|
expectedCommits: []*models.Commit{},
|
||||||
@ -44,7 +44,7 @@ func TestGetReflogCommits(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "some reflog entries",
|
testName: "some reflog entries",
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git log -g --abbrev=40 --format="%h%x00%ct%x00%gs%x00%p"`, reflogOutput, nil),
|
Expect(`git -c log.showSignature=false log -g --abbrev=40 --format="%h%x00%ct%x00%gs%x00%p"`, reflogOutput, nil),
|
||||||
|
|
||||||
lastReflogCommit: nil,
|
lastReflogCommit: nil,
|
||||||
expectedCommits: []*models.Commit{
|
expectedCommits: []*models.Commit{
|
||||||
@ -90,7 +90,7 @@ func TestGetReflogCommits(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "some reflog entries where last commit is given",
|
testName: "some reflog entries where last commit is given",
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git log -g --abbrev=40 --format="%h%x00%ct%x00%gs%x00%p"`, reflogOutput, nil),
|
Expect(`git -c log.showSignature=false log -g --abbrev=40 --format="%h%x00%ct%x00%gs%x00%p"`, reflogOutput, nil),
|
||||||
|
|
||||||
lastReflogCommit: &models.Commit{
|
lastReflogCommit: &models.Commit{
|
||||||
Sha: "c3c4b66b64c97ffeecde",
|
Sha: "c3c4b66b64c97ffeecde",
|
||||||
@ -114,7 +114,7 @@ func TestGetReflogCommits(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "when passing filterPath",
|
testName: "when passing filterPath",
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git log -g --abbrev=40 --format="%h%x00%ct%x00%gs%x00%p" --follow -- "path"`, reflogOutput, nil),
|
Expect(`git -c log.showSignature=false log -g --abbrev=40 --format="%h%x00%ct%x00%gs%x00%p" --follow -- "path"`, reflogOutput, nil),
|
||||||
|
|
||||||
lastReflogCommit: &models.Commit{
|
lastReflogCommit: &models.Commit{
|
||||||
Sha: "c3c4b66b64c97ffeecde",
|
Sha: "c3c4b66b64c97ffeecde",
|
||||||
@ -139,7 +139,7 @@ func TestGetReflogCommits(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "when command returns error",
|
testName: "when command returns error",
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git log -g --abbrev=40 --format="%h%x00%ct%x00%gs%x00%p"`, "", errors.New("haha")),
|
Expect(`git -c log.showSignature=false log -g --abbrev=40 --format="%h%x00%ct%x00%gs%x00%p"`, "", errors.New("haha")),
|
||||||
|
|
||||||
lastReflogCommit: nil,
|
lastReflogCommit: nil,
|
||||||
filterPath: "",
|
filterPath: "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user