Skip to content

Commit eb86738

Browse files
committed
Context with Timeout
1 parent 4a56da8 commit eb86738

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

services/gitdiff/gitdiff.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"regexp"
2121
"sort"
2222
"strings"
23+
"time"
2324

2425
"code.gitea.io/gitea/models"
2526
"code.gitea.io/gitea/modules/charset"
@@ -1216,9 +1217,9 @@ func GetDiffRangeWithWhitespaceBehavior(gitRepo *git.Repository, beforeCommitID,
12161217
return nil, err
12171218
}
12181219

1219-
// FIXME: graceful: These commands should likely have a timeout <- YES!!!
1220-
ctx, cancel := context.WithCancel(git.DefaultContext)
1220+
ctx, cancel := context.WithTimeout(git.DefaultContext, time.Duration(setting.Git.Timeout.Default)*time.Second)
12211221
defer cancel()
1222+
12221223
var cmd *exec.Cmd
12231224
if (len(beforeCommitID) == 0 || beforeCommitID == git.EmptySHA) && commit.ParentCount() == 0 {
12241225
diffArgs := []string{"diff", "--src-prefix=\\a/", "--dst-prefix=\\b/", "-M"}

0 commit comments

Comments
 (0)