Skip to content

Commit 92b5bad

Browse files
committed
Cleanup: simplify git arguments for reflog loading
The combination of --abbrev=40 and %h can be shortened to %H.
1 parent 8515c74 commit 92b5bad

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

pkg/commands/git_commands/reflog_commit_loader.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ func (self *ReflogCommitLoader) GetReflogCommits(hashPool *utils.StringPool, las
3030
cmdArgs := NewGitCmd("log").
3131
Config("log.showSignature=false").
3232
Arg("-g").
33-
Arg("--abbrev=40").
34-
Arg("--format=%h%x00%ct%x00%gs%x00%P").
33+
Arg("--format=%H%x00%ct%x00%gs%x00%P").
3534
ArgIf(filterAuthor != "", "--author="+filterAuthor).
3635
ArgIf(filterPath != "", "--follow", "--", filterPath).
3736
ToArgv()

pkg/commands/git_commands/reflog_commit_loader_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestGetReflogCommits(t *testing.T) {
3939
{
4040
testName: "no reflog entries",
4141
runner: oscommands.NewFakeRunner(t).
42-
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--abbrev=40", "--format=%h%x00%ct%x00%gs%x00%P"}, "", nil),
42+
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--format=%H%x00%ct%x00%gs%x00%P"}, "", nil),
4343

4444
lastReflogCommit: nil,
4545
expectedCommitOpts: []models.NewCommitOpts{},
@@ -49,7 +49,7 @@ func TestGetReflogCommits(t *testing.T) {
4949
{
5050
testName: "some reflog entries",
5151
runner: oscommands.NewFakeRunner(t).
52-
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--abbrev=40", "--format=%h%x00%ct%x00%gs%x00%P"}, reflogOutput, nil),
52+
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--format=%H%x00%ct%x00%gs%x00%P"}, reflogOutput, nil),
5353

5454
lastReflogCommit: nil,
5555
expectedCommitOpts: []models.NewCommitOpts{
@@ -95,7 +95,7 @@ func TestGetReflogCommits(t *testing.T) {
9595
{
9696
testName: "some reflog entries where last commit is given",
9797
runner: oscommands.NewFakeRunner(t).
98-
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--abbrev=40", "--format=%h%x00%ct%x00%gs%x00%P"}, reflogOutput, nil),
98+
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--format=%H%x00%ct%x00%gs%x00%P"}, reflogOutput, nil),
9999

100100
lastReflogCommit: models.NewCommit(hashPool, models.NewCommitOpts{
101101
Hash: "c3c4b66b64c97ffeecde",
@@ -119,7 +119,7 @@ func TestGetReflogCommits(t *testing.T) {
119119
{
120120
testName: "when passing filterPath",
121121
runner: oscommands.NewFakeRunner(t).
122-
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--abbrev=40", "--format=%h%x00%ct%x00%gs%x00%P", "--follow", "--", "path"}, reflogOutput, nil),
122+
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--format=%H%x00%ct%x00%gs%x00%P", "--follow", "--", "path"}, reflogOutput, nil),
123123

124124
lastReflogCommit: models.NewCommit(hashPool, models.NewCommitOpts{
125125
Hash: "c3c4b66b64c97ffeecde",
@@ -144,7 +144,7 @@ func TestGetReflogCommits(t *testing.T) {
144144
{
145145
testName: "when passing filterAuthor",
146146
runner: oscommands.NewFakeRunner(t).
147-
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--abbrev=40", "--format=%h%x00%ct%x00%gs%x00%P", "--author=John Doe <[email protected]>"}, reflogOutput, nil),
147+
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--format=%H%x00%ct%x00%gs%x00%P", "--author=John Doe <[email protected]>"}, reflogOutput, nil),
148148

149149
lastReflogCommit: models.NewCommit(hashPool, models.NewCommitOpts{
150150
Hash: "c3c4b66b64c97ffeecde",
@@ -169,7 +169,7 @@ func TestGetReflogCommits(t *testing.T) {
169169
{
170170
testName: "when command returns error",
171171
runner: oscommands.NewFakeRunner(t).
172-
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--abbrev=40", "--format=%h%x00%ct%x00%gs%x00%P"}, "", errors.New("haha")),
172+
ExpectGitArgs([]string{"-c", "log.showSignature=false", "log", "-g", "--format=%H%x00%ct%x00%gs%x00%P"}, "", errors.New("haha")),
173173

174174
lastReflogCommit: nil,
175175
filterPath: "",

0 commit comments

Comments
 (0)