summaryrefslogtreecommitdiffstats
path: root/modules/repofiles
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-10-14 05:49:33 +0100
committerGitHub <noreply@github.com>2020-10-14 07:49:33 +0300
commitedfebe65b14c167d5d14169334c4ba37dbebb700 (patch)
tree02d096827525589117a640e061f3b9b6df0d54d2 /modules/repofiles
parentaa73b7b7e57bd18637d2617183598d49a2102f66 (diff)
downloadgitea-edfebe65b14c167d5d14169334c4ba37dbebb700.tar.gz
gitea-edfebe65b14c167d5d14169334c4ba37dbebb700.zip
Finally fix diff names (#13136)
* Finally fix diff names #12771 attempted to fix diff by avoiding the git diff line as it is possible to have an ambiguous line here. #12254 attempted to fix diff by assuming that names would quoted if they needed to be and if one was quoted then both would be. Both of these were wrong. I have now discovered `--src-prefix` and `--dst-prefix` which means that we can set this in such a way to force the git diff to always be unambiguous. Therefore this PR rollsback most of the changes in #12771 and uses these options to fix this. Signed-off-by: Andrew Thornton <art27@cantab.net> * Update services/gitdiff/gitdiff.go * Update services/gitdiff/gitdiff.go * Update modules/repofiles/temp_repo.go * fix test Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/repofiles')
-rw-r--r--modules/repofiles/temp_repo.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/repofiles/temp_repo.go b/modules/repofiles/temp_repo.go
index e0d6c9fcb6..49a7ddbf19 100644
--- a/modules/repofiles/temp_repo.go
+++ b/modules/repofiles/temp_repo.go
@@ -292,7 +292,7 @@ func (t *TemporaryUploadRepository) DiffIndex() (*gitdiff.Diff, error) {
var diff *gitdiff.Diff
var finalErr error
- if err := git.NewCommand("diff-index", "--cached", "-p", "HEAD").
+ if err := git.NewCommand("diff-index", "--src-prefix=\\a/", "--dst-prefix=\\b/", "--cached", "-p", "HEAD").
RunInDirTimeoutEnvFullPipelineFunc(nil, 30*time.Second, t.basePath, stdoutWriter, stderr, nil, func(ctx context.Context, cancel context.CancelFunc) error {
_ = stdoutWriter.Close()
diff, finalErr = gitdiff.ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, stdoutReader)