summaryrefslogtreecommitdiffstats
path: root/services/gitdiff/gitdiff.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-07-29 18:53:04 +0100
committerGitHub <noreply@github.com>2020-07-29 13:53:04 -0400
commit2f6aadffa8243736825564cd1ce32d0d5a1eb391 (patch)
treeffd0d52a2303e04bee16bf019d5670b5c54d9256 /services/gitdiff/gitdiff.go
parentf2a6cd6401d3d04c7b6c769d39d68262abbdaae1 (diff)
downloadgitea-2f6aadffa8243736825564cd1ce32d0d5a1eb391.tar.gz
gitea-2f6aadffa8243736825564cd1ce32d0d5a1eb391.zip
Git 2.28 no longer permits diff with ... on unrelated branches (#12364)
* Git 2.28 no longer permits diff with ... on unrelated branches Signed-off-by: Andrew Thornton <art27@cantab.net> * need to check stderr
Diffstat (limited to 'services/gitdiff/gitdiff.go')
-rw-r--r--services/gitdiff/gitdiff.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go
index 09a826500b..85354784d4 100644
--- a/services/gitdiff/gitdiff.go
+++ b/services/gitdiff/gitdiff.go
@@ -752,6 +752,12 @@ func GetDiffRangeWithWhitespaceBehavior(repoPath, beforeCommitID, afterCommitID
shortstatArgs = []string{git.EmptyTreeSHA, afterCommitID}
}
diff.NumFiles, diff.TotalAddition, diff.TotalDeletion, err = git.GetDiffShortStat(repoPath, shortstatArgs...)
+ if err != nil && strings.Contains(err.Error(), "no merge base") {
+ // git >= 2.28 now returns an error if base and head have become unrelated.
+ // previously it would return the results of git diff --shortstat base head so let's try that...
+ shortstatArgs = []string{beforeCommitID, afterCommitID}
+ diff.NumFiles, diff.TotalAddition, diff.TotalDeletion, err = git.GetDiffShortStat(repoPath, shortstatArgs...)
+ }
if err != nil {
return nil, err
}