summaryrefslogtreecommitdiffstats
path: root/pkg/commands/loaders
diff options
context:
space:
mode:
authorRyooooooga <eial5q265e5@gmail.com>2022-05-04 19:41:37 +0900
committerRyooooooga <eial5q265e5@gmail.com>2022-05-10 19:47:07 +0900
commitf789e213770880e30a9d3f891c034d75b718e1ce (patch)
tree173a8c0dbcc528f8588f64a78191a12dd21c9882 /pkg/commands/loaders
parent8c04118bb144e9f21fc6e1d8fa2fcfc159e21a56 (diff)
perf: improve loading speed of commits and reflog when `log.showSignature=true`
Diffstat (limited to 'pkg/commands/loaders')
-rw-r--r--pkg/commands/loaders/commits.go14
-rw-r--r--pkg/commands/loaders/commits_test.go4
-rw-r--r--pkg/commands/loaders/reflog_commits.go2
-rw-r--r--pkg/commands/loaders/reflog_commits_test.go10
4 files changed, 14 insertions, 16 deletions
diff --git a/pkg/commands/loaders/commits.go b/pkg/commands/loaders/commits.go
index 4a870643b..c21b622d8 100644
--- a/pkg/commands/loaders/commits.go
+++ b/pkg/commands/loaders/commits.go
@@ -89,14 +89,12 @@ func (self *CommitLoader) GetCommits(opts GetCommitsOptions) ([]*models.Commit,
}
err = self.getLogCmd(opts).RunAndProcessLines(func(line string) (bool, error) {
- if canExtractCommit(line) {
- commit := self.extractCommitFromLine(line)
- if commit.Sha == firstPushedCommit {
- passedFirstPushedCommit = true
- }
- commit.Status = map[bool]string{true: "unpushed", false: "pushed"}[!passedFirstPushedCommit]
- commits = append(commits, commit)
+ commit := self.extractCommitFromLine(line)
+ if commit.Sha == firstPushedCommit {
+ passedFirstPushedCommit = true
}
+ commit.Status = map[bool]string{true: "unpushed", false: "pushed"}[!passedFirstPushedCommit]
+ commits = append(commits, commit)
return false, nil
})
if err != nil {
@@ -435,7 +433,7 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
return self.cmd.New(
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),
orderFlag,
allFlag,
diff --git a/pkg/commands/loaders/commits_test.go b/pkg/commands/loaders/commits_test.go
index e0e8fbad6..a2a68fccc 100644
--- a/pkg/commands/loaders/commits_test.go
+++ b/pkg/commands/loaders/commits_test.go
@@ -40,7 +40,7 @@ func TestGetCommits(t *testing.T) {
opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
runner: oscommands.NewFakeRunner(t).
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{},
expectedError: nil,
@@ -54,7 +54,7 @@ func TestGetCommits(t *testing.T) {
// here it's seeing which commits are yet to be pushed
Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
// 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'
Expect(`git merge-base "HEAD" "master"`, "26c07b1ab33860a1a7591a0638f9925ccf497ffa", nil),
diff --git a/pkg/commands/loaders/reflog_commits.go b/pkg/commands/loaders/reflog_commits.go
index 4d73adb24..fe4e5e956 100644
--- a/pkg/commands/loaders/reflog_commits.go
+++ b/pkg/commands/loaders/reflog_commits.go
@@ -32,7 +32,7 @@ func (self *ReflogCommitLoader) GetReflogCommits(lastReflogCommit *models.Commit
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
err := cmdObj.RunAndProcessLines(func(line string) (bool, error) {
fields := strings.SplitN(line, "\x00", 4)
diff --git a/pkg/commands/loaders/reflog_commits_test.go b/pkg/commands/loaders/reflog_commits_test.go
index f8d5bff36..8a82d27ac 100644
--- a/pkg/commands/loaders/reflog_commits_test.go
+++ b/pkg/commands/loaders/reflog_commits_test.go
@@ -34,7 +34,7 @@ func TestGetReflogCommits(t *testing.T) {
{
testName: "no reflog entries",
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,
expectedCommits: []*models.Commit{},
@@ -44,7 +44,7 @@ func TestGetReflogCommits(t *testing.T) {
{
testName: "some reflog entries",
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,
expectedCommits: []*models.Commit{
@@ -90,7 +90,7 @@ func TestGetReflogCommits(t *testing.T) {
{
testName: "some reflog entries where last commit is given",
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{
Sha: "c3c4b66b64c97ffeecde",
@@ -114,7 +114,7 @@ func TestGetReflogCommits(t *testing.T) {
{
testName: "when passing filterPath",
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{
Sha: "c3c4b66b64c97ffeecde",
@@ -139,7 +139,7 @@ func TestGetReflogCommits(t *testing.T) {
{
testName: "when command returns error",
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,
filterPath: "",