aboutsummaryrefslogtreecommitdiff
path: root/services/gitdiff/gitdiff.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/gitdiff/gitdiff.go')
-rw-r--r--services/gitdiff/gitdiff.go33
1 files changed, 2 insertions, 31 deletions
diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go
index 97daadbc6..37dc0e114 100644
--- a/services/gitdiff/gitdiff.go
+++ b/services/gitdiff/gitdiff.go
@@ -1417,37 +1417,8 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff
}
diff.Start = opts.SkipTo
- var checker *git.CheckAttributeReader
-
- if git.CheckGitVersionAtLeast("1.7.8") == nil {
- indexFilename, worktree, deleteTemporaryFile, err := gitRepo.ReadTreeToTemporaryIndex(opts.AfterCommitID)
- if err == nil {
- defer deleteTemporaryFile()
-
- checker = &git.CheckAttributeReader{
- Attributes: []string{"linguist-vendored", "linguist-generated", "linguist-language", "gitlab-language"},
- Repo: gitRepo,
- IndexFile: indexFilename,
- WorkTree: worktree,
- }
- ctx, cancel := context.WithCancel(gitRepo.Ctx)
- if err := checker.Init(ctx); err != nil {
- log.Error("Unable to open checker for %s. Error: %v", opts.AfterCommitID, err)
- } else {
- go func() {
- err := checker.Run()
- if err != nil && err != ctx.Err() {
- log.Error("Unable to open checker for %s. Error: %v", opts.AfterCommitID, err)
- }
- cancel()
- }()
- }
- defer func() {
- _ = checker.Close()
- cancel()
- }()
- }
- }
+ checker, deferable := gitRepo.CheckAttributeReader(opts.AfterCommitID)
+ defer deferable()
for _, diffFile := range diff.Files {