1706463645.FILE5_45-79-ged96f0ee.recognize-unified-diff-output-joerg-jenderek.patch 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. Subject: Recognize unified diff output (Joerg Jenderek)
  2. Origin: FILE5_45-79-ged96f0ee <https://github.com/file/file/commit/FILE5_45-79-ged96f0ee>
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Sun Jan 28 17:40:45 2024 +0000
  5. Bug-Debian: https://bugs.debian.org/1063522
  6. --- a/magic/Magdir/diff
  7. +++ b/magic/Magdir/diff
  8. @@ -9,25 +9,67 @@
  9. >&0 search/1024 \n---\040 context diff output text
  10. !:mime text/x-diff
  11. 0 search/1 Only\040in\040 diff output text
  12. +# diff output text output text (strength=38=38+0) after unified diff output (strength=131=38+93)
  13. +#!:strength +0
  14. !:mime text/x-diff
  15. +#!:mime text/x-patch
  16. +!:ext diff
  17. 0 search/1 Common\040subdirectories:\040 diff output text
  18. !:mime text/x-diff
  19. +# URL: https://en.wikipedia.org/wiki/Diff#Extensions
  20. +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/diff-rcs.trid.xml
  21. +# Note: called "RCS/CVS diff output" by TrID
  22. +# and "Differences between files" by shared MIME-info database from freedesktop.org
  23. 0 search/1 Index: RCS/CVS diff output text
  24. +# RCS/CVS diff output text (strength=36=36+0) after unified diff output (strength=131=38+93)
  25. +#!:strength +0
  26. !:mime text/x-diff
  27. +#!:mime text/x-patch
  28. +!:ext diff/patch
  29. # bsdiff: file(1) magic for bsdiff(1) output
  30. 0 string/b BSDIFF40 bsdiff(1) patch file
  31. # unified diff
  32. -0 search/4096 ---\040
  33. ->&0 search/1024 \n
  34. ->>&0 search/1 +++\040
  35. ->>>&0 search/1024 \n
  36. ->>>>&0 search/1 @@ unified diff output text
  37. +# URL: http://fileformats.archiveteam.org/wiki/Unified_diff
  38. +# https://en.wikipedia.org/wiki/Diff_utility#Unified_format
  39. +# Reference: https://www.artima.com/weblogs/viewpost.jsp?thread=164293
  40. +# http://mark0.net/download/triddefs_xml.7z/defs/d/diff-unified.trid.xml
  41. +# Note: called "unified diff output" by TrID and
  42. +# "Differences between files" by shared MIME-info database from freedesktop.org
  43. +# use b flag to forces the test to be done for binary files (non ASCII text like with Ctrl-D Ctrl-V Ctrl-Z)
  44. +0 search/4096/b ---\040
  45. +!:strength + 93
  46. +>0 use diff-unified
  47. +# most samples are just pure ASCII text like: ShellR64.patch
  48. +0 search/11054 ---\040
  49. +# unified diff (strength=131=38+93) before
  50. +# HTML document text (strength=170,90,71,53,52,51,49) POSIX shell script (fix-qt5.6-build.patch strength=130 ./commands)
  51. +# JavaScript source (strength=112,84,81,80,79,78,72,69) C++ source (strength=71,70,69,68,67,54),
  52. +# Python script (strength=69,67,63,60,58,57,56,54,52,37)LaTeX document text (strength=62,56,55,51,43)
  53. +# TeX document (strength=51,38) C source (strength=41,39,37)
  54. +# exported SGML document (strength=39,28) diff output text (strength=38=38+0)
  55. +# Pascal source (strength=37) RCS/CVS diff (strength=36=36+0),
  56. +# Algol 68 source (strength=?) CSV ASCII text (strength=?)
  57. +!:strength + 93
  58. +>0 use diff-unified
  59. +# check for 3 characteristic lines of unified diff
  60. +0 name diff-unified
  61. +>0 search/11084 +++\040
  62. +>>&0 search/1024 \n
  63. +# at signs line sometimes other (with 2 space chars before) like: indent-header.patch
  64. +>>>&0 search/2 @@\040- unified diff output text
  65. !:mime text/x-diff
  66. -!:strength + 90
  67. +#!:mime text/x-patch
  68. +# https://file-extension.net/seeker/file_extension_dif file_extension_pch file_extension_rej
  69. +!:ext diff/patch/dif/pch/rej
  70. +# GRR: mainly for debugging purpose for variants with text before real diff output
  71. +>>>>0 string !---\040
  72. +>>>>>0 string x \b, 1st line "%s"
  73. +>>>>>>&1 string x \b, 2nd line "%s"
  74. +>>>>>>>&1 string x \b, 3rd line "%s"
  75. # librsync -- the library for network deltas
  76. #