diff options
author | zeripath <art27@cantab.net> | 2021-12-19 04:19:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-19 05:19:25 +0100 |
commit | f1e85622da0492fa01d8449eb938197cd4fa65bf (patch) | |
tree | 3d0b6c6fe2b93083269047e778e8da2f9dcb2f86 /modules | |
parent | 487ce3b49e5fb4ef79ded696532f071293cf10d9 (diff) | |
download | gitea-f1e85622da0492fa01d8449eb938197cd4fa65bf.tar.gz gitea-f1e85622da0492fa01d8449eb938197cd4fa65bf.zip |
Improve TestPatch to use git read-tree -m and implement git-merge-one-file functionality (#18004)
The current TestPatch conflict code uses a plain git apply which does not properly
account for 3-way merging. However, we can improve things using `git read-tree -m` to
do a three-way merge then follow the algorithm used in merge-one-file. We can also use
`--patience` and/or `--histogram` to generate a nicer diff for applying patches too.
Fix #13679
Fix #6417
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/git/repo_compare.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/git/repo_compare.go b/modules/git/repo_compare.go index 4342eb4b2f..5fe37aed7b 100644 --- a/modules/git/repo_compare.go +++ b/modules/git/repo_compare.go @@ -237,7 +237,11 @@ func (repo *Repository) GetDiff(base, head string, w io.Writer) error { // GetDiffBinary generates and returns patch data between given revisions, including binary diffs. func (repo *Repository) GetDiffBinary(base, head string, w io.Writer) error { - return NewCommandContext(repo.Ctx, "diff", "-p", "--binary", base, head). + if CheckGitVersionAtLeast("1.7.7") == nil { + return NewCommandContext(repo.Ctx, "diff", "-p", "--binary", "--histogram", base, head). + RunInDirPipeline(repo.Path, w, nil) + } + return NewCommandContext(repo.Ctx, "diff", "-p", "--binary", "--patience", base, head). RunInDirPipeline(repo.Path, w, nil) } |