jgit/org.eclipse.jgit.test/tst-rsrc
Thomas Wolf d2846cc8b2 ApplyCommand: convert to git internal format before applying patch
Applying a patch on Windows failed if the patch had the (normal)
single-LF line endings, but the file on disk had the usual Windows
CR-LF line endings.

Git (and JGit) compute diffs on the git-internal blob, i.e., after
CR-LF transformation and clean filtering. Applying patches to files
directly is thus incorrect and may fail if CR-LF settings don't
match, or if clean/smudge filtering is involved.

Change ApplyCommand to run the file content through the check-in
filters before applying the patch, and run the result through the
check-out filters. This makes patch application succeed even if the
patch has single-LFs, but the file has CR-LF and core.autocrlf is
true.

Add tests for various combinations of line endings in the file and in
the patch, and a test to verify the clean/smudge handling.

See also [1].

Running the file though clean/smudge may give strange results with
LFS-managed files. JGit's DiffFormatter has some extra code and
applies the smudge filter again after having run the file through
the check-in filters (CR-LF and clean). So JGit can actually produce
a diff on LFS-managed files using the normal diff machinery. (If it
doesn't run out of memory, that is. After all, LFS is intended for
_large_ files.) How such a diff would be applied with either C git
or JGit is entirely unclear; neither has any code for this special
case. Compare also [2].

Note that C git just doesn't know about LFS and always diffs after
the check-in filter chain, so for LFS files, it'll produce a diff
of the LFS pointers.

[1] https://github.com/git/git/commit/c24f3abac
[2] https://github.com/git-lfs/git-lfs/issues/440

Bug: 571585
Change-Id: I8f71ff26313b5773ff1da612b0938ad2f18751f5
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-05-18 17:23:34 +02:00
..
META-INF/services Ignore trailing comments in transport SPI parsing 2012-03-21 14:07:55 -07:00
org/eclipse/jgit ApplyCommand: convert to git internal format before applying patch 2021-05-18 17:23:34 +02:00
jgit-s3-config.disabled.properties Adding AES Walk Encryption support in http://www.jets3t.org/ mode 2015-10-18 19:14:31 +00:00
jgit-s3-config.policy.bucket.json Adding AES Walk Encryption support in http://www.jets3t.org/ mode 2015-10-18 19:14:31 +00:00
jgit-s3-config.policy.user.json Adding AES Walk Encryption support in http://www.jets3t.org/ mode 2015-10-18 19:14:31 +00:00
jgit-s3-connection-v-0.properties Adding JGitV1 and JGitV2 Walk Encryption 2015-10-18 23:22:56 +02:00
jgit-s3-connection-v-1.properties Adding JGitV1 and JGitV2 Walk Encryption 2015-10-18 23:22:56 +02:00
jgit-s3-connection-v-2.properties Adding JGitV1 and JGitV2 Walk Encryption 2015-10-18 23:22:56 +02:00
log4j.properties Disable debug log for FS in org.eclipse.jgit.test 2019-08-10 20:32:07 +02:00
simplelogger.properties Bazel: enable logging for tests in org.eclipse.jgit.test 2019-08-10 01:21:18 +02:00