Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair and Improve GetDiffRangeWithWhitespaceBehavior #16894

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Context with Timeout
  • Loading branch information
6543 committed Aug 30, 2021
commit eb86738271a6e41c89f07dfa50ad13fff7a1fa52
5 changes: 3 additions & 2 deletions services/gitdiff/gitdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"regexp"
"sort"
"strings"
"time"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/charset"
Expand Down Expand Up @@ -1216,9 +1217,9 @@ func GetDiffRangeWithWhitespaceBehavior(gitRepo *git.Repository, beforeCommitID,
return nil, err
}

// FIXME: graceful: These commands should likely have a timeout <- YES!!!
ctx, cancel := context.WithCancel(git.DefaultContext)
ctx, cancel := context.WithTimeout(git.DefaultContext, time.Duration(setting.Git.Timeout.Default)*time.Second)
defer cancel()

var cmd *exec.Cmd
if (len(beforeCommitID) == 0 || beforeCommitID == git.EmptySHA) && commit.ParentCount() == 0 {
diffArgs := []string{"diff", "--src-prefix=\\a/", "--dst-prefix=\\b/", "-M"}
Expand Down