Skip to content

Commit 32c1128

Browse files
Chi-IrohThomas Sayen
authored andcommitted
Use git log instead of git rev-list
1 parent 1610a63 commit 32c1128

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

modules/git/repo_commit.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package git
66

77
import (
88
"bytes"
9+
"fmt"
910
"io"
1011
"os"
1112
"strconv"
@@ -232,7 +233,9 @@ func (repo *Repository) CommitsByFileAndRange(opts CommitsByFileAndRangeOptions)
232233
}()
233234
go func() {
234235
stderr := strings.Builder{}
235-
gitCmd := NewCommand("rev-list").
236+
gitCmd := NewCommand(repo.Ctx, "--no-pager", "log").
237+
AddOptionFormat("--follow").
238+
AddOptionFormat("--pretty=format:%%H").
236239
AddOptionFormat("--max-count=%d", setting.Git.CommitsRangeSize).
237240
AddOptionFormat("--skip=%d", (opts.Page-1)*setting.Git.CommitsRangeSize)
238241
gitCmd.AddDynamicArguments(opts.Revision)
@@ -248,19 +251,23 @@ func (repo *Repository) CommitsByFileAndRange(opts CommitsByFileAndRangeOptions)
248251
}
249252

250253
gitCmd.AddDashesAndList(opts.File)
254+
fmt.Print(gitCmd)
255+
fmt.Fprint(os.Stdout, "")
251256
err := gitCmd.Run(repo.Ctx, &RunOpts{
252257
Dir: repo.Path,
253258
Stdout: stdoutWriter,
254259
Stderr: &stderr,
255260
})
256-
if err != nil {
261+
fmt.Print("1 ", err)
262+
if err != nil && err != io.ErrUnexpectedEOF {
257263
_ = stdoutWriter.CloseWithError(ConcatenateError(err, (&stderr).String()))
258264
} else {
259265
_ = stdoutWriter.Close()
260266
}
261267
}()
262268

263269
objectFormat, err := repo.GetObjectFormat()
270+
fmt.Print("object", err)
264271
if err != nil {
265272
return nil, err
266273
}
@@ -270,8 +277,9 @@ func (repo *Repository) CommitsByFileAndRange(opts CommitsByFileAndRangeOptions)
270277
shaline := make([]byte, length+1)
271278
for {
272279
n, err := io.ReadFull(stdoutReader, shaline)
280+
fmt.Print("io", err)
273281
if err != nil || n < length {
274-
if err == io.EOF {
282+
if err == io.EOF || err == io.ErrUnexpectedEOF {
275283
err = nil
276284
}
277285
return commits, err

0 commit comments

Comments
 (0)