Skip to content

Commit 3979e2a

Browse files
committed
Fix GetDiffShortStat. It now correctly returns the stat between two revs.
When using the base...head pattern git diff works out the common merge base and then compare the mergebase to the head revision. This results in incorrect stats if the you are comparing a y shaped branches e.g.: sets of revisions. For example on the pull requests view changes tab when you select since revision, when the last revision just changed the commit msg the returned content is correctly empty (because there is no file content change) but the stat is not because the comparasion is not made between the actual revision heads but their merge head. Regural /compare/base...head comparisions which also use this function are not affected by this change because they *themselves* work out the common merge base and they use *that* to call this function. So they were doing this anyway instead of relying on this function to compute the common merge base. I checked all paths (I think...) that leads to this function and all calls to this seem to be correct after this change.
1 parent c26bb2d commit 3979e2a

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

modules/git/repo_compare.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,8 @@ func (repo *Repository) GetDiffNumChangedFiles(base, head string) (int, error) {
131131

132132
// GetDiffShortStat counts number of changed files, number of additions and deletions
133133
func (repo *Repository) GetDiffShortStat(base, head string) (numFiles, totalAdditions, totalDeletions int, err error) {
134-
numFiles, totalAdditions, totalDeletions, err = GetDiffShortStat(repo.Path, base+"..."+head)
135-
if err != nil && strings.Contains(err.Error(), "no merge base") {
136134
return GetDiffShortStat(repo.Path, base, head)
137135
}
138-
return
139-
}
140136

141137
// GetDiffShortStat counts number of changed files, number of additions and deletions
142138
func GetDiffShortStat(repoPath string, args ...string) (numFiles, totalAdditions, totalDeletions int, err error) {

0 commit comments

Comments
 (0)