* Git 2.28 no longer permits diff with ... on unrelated branches Signed-off-by: Andrew Thornton <art27@cantab.net> * need to check stderr
Showing the changes to services/gitdiff/gitdiff.go (1 of 5 files). Show all
Unified · Split
| @@ -752,6 +752,12 @@ func GetDiffRangeWithWhitespaceBehavior(repoPath, beforeCommitID, afterCommitID · 751 unmodified lines | ||
| 752 | 752 | shortstatArgs = []string{git.EmptyTreeSHA, afterCommitID} |
| 753 | 753 | } |
| 754 | 754 | diff.NumFiles, diff.TotalAddition, diff.TotalDeletion, err = git.GetDiffShortStat(repoPath, shortstatArgs...) |
| 755 | + if err != nil && strings.Contains(err.Error(), "no merge base") { | |
| 756 | + // git >= 2.28 now returns an error if base and head have become unrelated. | |
| 757 | + // previously it would return the results of git diff --shortstat base head so let's try that... | |
| 758 | + shortstatArgs = []string{beforeCommitID, afterCommitID} | |
| 759 | + diff.NumFiles, diff.TotalAddition, diff.TotalDeletion, err = git.GetDiffShortStat(repoPath, shortstatArgs...) | |
| 760 | + } | |
| 755 | 761 | if err != nil { |
| 756 | 762 | return nil, err |
| 757 | 763 | } |