-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Since 1.12.4 diff not working with blanks in filename or pathname #12768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like there can be no way of actually detemining which file has been changed from the diff line: diff --git a/a b/file b/a a/file b/a b/file b/a a/file
index d2186f1..f5c8ed2 100644
--- a/a b/file b/a a/file
+++ b/a b/file b/a a/file
@@ -1,3 +1,2 @@
Create a weird file.
-and what does diff do here?
\ No newline at end of file |
Could we somehow refactor and use output git diff --name-only or git diff --name-status for this instead of looking at the diff itself? |
zeripath
added a commit
to zeripath/gitea
that referenced
this issue
Sep 8, 2020
Following further testing it has become apparent that the diff line cannot be used to determine filenames for diffs with any sort of predictability the answer therefore is to use the other lines that are provided with a diff Fix go-gitea#12768 Signed-off-by: Andrew Thornton <[email protected]>
zeripath
added a commit
that referenced
this issue
Sep 9, 2020
Following further testing it has become apparent that the diff line cannot be used to determine filenames for diffs with any sort of predictability the answer therefore is to use the other lines that are provided with a diff Fix #12768 Signed-off-by: Andrew Thornton <[email protected]>
Hopefully this won't reveal (yet) another bug |
zeripath
added a commit
to zeripath/gitea
that referenced
this issue
Sep 9, 2020
Backport go-gitea#12771 Following further testing it has become apparent that the diff line cannot be used to determine filenames for diffs with any sort of predictability the answer therefore is to use the other lines that are provided with a diff Fix go-gitea#12768 Signed-off-by: Andrew Thornton <[email protected]>
zeripath
added a commit
that referenced
this issue
Sep 9, 2020
Backport #12771 Following further testing it has become apparent that the diff line cannot be used to determine filenames for diffs with any sort of predictability the answer therefore is to use the other lines that are provided with a diff Fix #12768 Signed-off-by: Andrew Thornton <[email protected]>
7 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
[x]
):Description
Gitea Diff shows either wrong filenames or produces HTTP 500 if there is a blank in the filename/pathname of a changed file.
This bug applies only if git, but this seems to be default, does not quote the filenames at diff output.
Bug is since issue #12554 (#12575) - which became live in 1.12.4
Detail
Originally posted by @fashberg in #12554 (comment)
This fix breaks filenames with blanks in path (filename or foldername).
If you have
"diff --git a/folder/filename withBlank b/folder/filename withBlank"
you get now this wrong variable assignments:
And the this two lines at https://github.com/go-gitea/gitea/blob/master/services/gitdiff/gitdiff.go#L592
are deleting the first two characters resulting in
In the diff you see a renaming
filename → thBlank
and if you click on the link to 'Show File' it links to 'thBlank' which results in 404.The bug is getting worse if the filename has only a single character after the first blank, e.g.
test - file
Resulting in
Because strlen of b is only 2 the substring(b, 2)/ (
b = b[2:]
) will not work because string is too short, resulting in Error 500So the
middle = strings.Index(line, " b/")
hack was not so bad.Now filenames with blanks are completely broken in 1.12.4 and master!
Why ignoring the lines with
--- a/xxxx
and+++ b/xxxx
?There you can cat the real filename without any quoting problems. OK, new files are having
--- /dev/null
and maybe there are some more special cases.Kind Regards
Folke
The text was updated successfully, but these errors were encountered: