-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
--diff output does not git apply
cleanly when the diff context includes EOF
#526
Comments
Interesting, does it work with GNU patch? |
Yeah, it does, good idea! Totally forgot about GNU patch. That's a good workaround. Thanks! |
@benkuhn Does GNU patch work? If yes then we need to understand what the failure mode here is. If this is really our diff's fault, I see no problem fixing this. |
Sorry for not being clear! GNU patch does successfully apply the Black patch. Here is the output of
And here is the output of
The error message for
The failure mode is that the Black patch declares that it is patching two lines, and
|
Here's a repro where the patch does not apply with either tool:
I think GNU patch detects it as "previously applied" because the patch shows the file going from 3 lines long to 2 lines long, but patch is already ignoring the trailing newline so sees the file as 2 lines long. |
I have a similar issue, though it could also be considered separate, so please advise if I'd better open a new issue about it. I also have a situation where Input file: #!/usr/bin/env python
Import("env")
if "RD_GLSL" in env["BUILDERS"]:
env.RD_GLSL("ssao.glsl")
env.RD_GLSL("ssao_minify.glsl")
env.RD_GLSL("ssao_blur.glsl")
env.RD_GLSL("roughness_limiter.glsl")
env.RD_GLSL("screen_space_reflection.glsl")
env.RD_GLSL("screen_space_reflection_filter.glsl")
env.RD_GLSL("screen_space_reflection_scale.glsl")
env.RD_GLSL("specular_merge.glsl")
(has trailing whitespace on the last two lines) $ black -q --diff SCsub
--- SCsub 2020-04-02 07:09:58.106534 +0000
+++ SCsub 2020-04-02 07:11:32.927345 +0000
@@ -9,8 +9,6 @@
env.RD_GLSL("roughness_limiter.glsl")
env.RD_GLSL("screen_space_reflection.glsl")
env.RD_GLSL("screen_space_reflection_filter.glsl")
env.RD_GLSL("screen_space_reflection_scale.glsl")
env.RD_GLSL("specular_merge.glsl")
-
-
On the other hand, diff --git a/SCsub b/SCsub
index c112b93..1e70b36 100644
--- a/SCsub
+++ b/SCsub
@@ -11,5 +11,3 @@ if "RD_GLSL" in env["BUILDERS"]:
env.RD_GLSL("screen_space_reflection_filter.glsl")
env.RD_GLSL("screen_space_reflection_scale.glsl")
env.RD_GLSL("specular_merge.glsl")
-
- I first thought that the problem might be the extra newline at the end of the black diff, but removing it doesn't make the diff apply. I had to remove the extra two lines of context and amend the line |
Nevermind, the problem is exactly as described by @benkuhn. The 5 lines of context come from Line 3882 in 9ed2542
Here's the (git) diff applied on my generated diff --git a/diff-black b/diff-black
index 055e76d..af081b5 100644
--- a/diff-black
+++ b/diff-black
@@ -1,6 +1,6 @@
--- SCsub 2020-04-02 07:33:18.592786 +0000
+++ SCsub 2020-04-02 07:35:24.294130 +0000
-@@ -9,8 +9,6 @@
+@@ -9,7 +9,5 @@
env.RD_GLSL("roughness_limiter.glsl")
env.RD_GLSL("screen_space_reflection.glsl")
env.RD_GLSL("screen_space_reflection_filter.glsl")
@@ -8,4 +8,3 @@
env.RD_GLSL("specular_merge.glsl")
-
-
- |
Found a potential fix, I'll make a PR. |
`split("\n")` includes a final empty element `""` if the final line ends with `\n` (as it should for POSIX-compliant text files), which then became an extra `"\n"`. `splitlines()` solves that, but there's a caveat, as it will split on other types of line breaks too (like `\r`), which may not be desired. Fixes psf#526.
`split("\n")` includes a final empty element `""` if the final line ends with `\n` (as it should for POSIX-compliant text files), which then became an extra `"\n"`. `splitlines()` solves that, but there's a caveat, as it will split on other types of line breaks too (like `\r`), which may not be desired. Fixes psf#526.
`split("\n")` includes a final empty element `""` if the final line ends with `\n` (as it should for POSIX-compliant text files), which then became an extra `"\n"`. `splitlines()` solves that, but there's a caveat, as it will split on other types of line breaks too (like `\r`), which may not be desired. Fixes psf#526.
`split("\n")` includes a final empty element `""` if the final line ends with `\n` (as it should for POSIX-compliant text files), which then became an extra `"\n"`. `splitlines()` solves that, but there's a caveat, as it will split on other types of line breaks too (like `\r`), which may not be desired. Fixes #526.
`split("\n")` includes a final empty element `""` if the final line ends with `\n` (as it should for POSIX-compliant text files), which then became an extra `"\n"`. `splitlines()` solves that, but there's a caveat, as it will split on other types of line breaks too (like `\r`), which may not be desired. Fixes #526.
Thanks for making an awesome tool! I ran across this issue while trying to make a script that asks before applying changes. (Obviously I could reapply the changes by running
black
again so it's not too important, but being able to cache the diff so the apply is faster would be nice, and avoid a race condition if someone edits a file in the middle)Steps to reproduce issue:
The problem is that the diff includes an extra newline at the end compared to what git expects:
The text was updated successfully, but these errors were encountered: