Skip to content
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

[BUG] Delete patches aren't being generated for deleted binary files #9

Open
hypherionmc opened this issue May 4, 2024 · 5 comments

Comments

@hypherionmc
Copy link

Hey, so not sure if this is a bug or intentional.

If you delete a folder, it will generate patches for all the text files in the folder to be deleted, but will leave behind any binary files like images, jar files etc.

Not sure if #8 fixes this or not

@covers1624
Copy link
Member

If i'm remembering right, there is a patch spec for binary files.

I believe the PR specified may delete these files from the output, however, will not generate patches for these files.

I suspect we will need to add support for the binary patch format.

@hypherionmc
Copy link
Author

Looks like this is how github sees deleted files:

diff --git a/Forge/src/main/resources/mmode_icon.png b/Forge/src/main/resources/mmode_icon.png
deleted file mode 100644
index 5dd7c15008f434bc3159588bb0d705d9798b57a9..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 184668
zcmeFZ^;gsH|35xTN<va;rKP01q(izpq$H(#C@2B~(%mI3-6ajuNW<tHj2^JTzQgD1
z{U>~X`|O;-b<WP?+7<V>-EX%$L};if;Nei<0000yB}G{+00131L<e9!LH+_#vxNcx
zID!r`G8!IQ3UBF@<YWZ6g#`pScsRKM0N>24WFH;vMY8aT4#5tMc*4lUNk@AvR7JcF
z#W>E_+}MQ5-9G@Y1Y~vGWHsZ8v3OY4LkeW#YF<TtLD8%^LVqDU`_YYrGFj<;<qJ@|
zA7m^8L<<de%;}g|wSxrBwE}*?Lot4<8eoS!%`+g`*z5lm9c5>MiSqOmfaU~PcdM&=
zOLilVnuZ#<@ZBkm_=dcr6`$@F_IgJ0dk+ASlh|VTiW{Jj`hD;GX3^vY`LK|<ekNm+
z`fzF^-@EZQ%HyvLKlA7%c$~8v2VSSy5C~uJgo(Wv^%&o@Io)1i-ij6`>iiyO@q&C0
z>!yXLlgT>NQ|YVJfa`Y6i$FC2089J|=dOqLdnXR-cov?|99w>Xb;V)x(`hb)KNG~G
z1pVWGj5vuHO1`~dGSU7Toj@G5F){IOFRK5~8+^fN`c3YIv=@d{8}0zx3AiDNpYw~_
zSE36-!a{GHIh;FLW`U;gjCiPbvRN4L<b^ElP4BgSa2g)qSFugQ;$67211Z4t2t}jq
zK77oA3lLe`>4hKkk)}1!Osj8`-Hxq%WyM4VCC8DKYaeo#gAbH351i2IT!rjd`d%am
[REDACTED]

Maybe there is a way to generate a special kind of patch, similar to /dev/null, just to indicate that the file should be removed.

Would actually be nice if git patches actually supported adding binary files from patches as well lol

@covers1624
Copy link
Member

Support for git formatted patches is likely something that can be supported in the future. At the moment DiffPatch only supports single-file unified patches. Adding support for the other formats is a bit of a large project and will require some reworks.

There are several things to consider with delete patches, as different projects may have different requirements.

  • Deleting text files currently produces the entire file as - lines, with +++ /dev/null.
    • Some projects aren't allowed to do this due to license restrictions.
    • We can potentially add a flag to allow files with +++ /dev/null always match regardless of their - context lines. (with a similar argument for creating patches.)
  • Deleting/Creating binary files currently has no defined format.
    • Cloudbees diff4j appears to define some format. But doesn't appear to include anything for creating these patches. I can't seem to find any info on this format anywhere.
    • GNU Patch does not appear to have any support for binary patches either. It can run in 'binary mode' which is close but not enough.
    • We may need to roll our own non-standard format for create patches. I don't think proper binary patches should be a goal (at the moment).
    • Delete binary patches can likely be handled with implicit - lines support.

@hypherionmc
Copy link
Author

No problem. It's not a deal breaker for me as of yet. I just leave the binary files in place, since they have no affect on the final application. Would be fine for a future update :)

@Chicken-Bones
Copy link

I've discussed this with covers a few times in recent months, and the core issue is that DiffPatch doesn't have any support for binary files. It was developed because there is no existing tool which provides the FUZZY patch algorithm, but this only applies to text files.

Support for different binary file workflows is absolutely being considered as a result of this issue, so thankyou for your patience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants