1b6cee71dSXin LI 2b6cee71dSXin LI#------------------------------------------------------------------------------ 3*ae316d1dSXin LI# $File: diff,v 1.21 2024/07/13 14:47:09 christos Exp $ 4b6cee71dSXin LI# diff: file(1) magic for diff(1) output 5b6cee71dSXin LI# 6*ae316d1dSXin LI# Update: Joerg Jenderek 7*ae316d1dSXin LI# URL: https://en.wikipedia.org/wiki/Diff 8*ae316d1dSXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/diff.trid.xml 9*ae316d1dSXin LI# Note: called "diff output text" by TrID and 10*ae316d1dSXin LI# "Differences between files" by shared MIME-info database from freedesktop.org 11*ae316d1dSXin LI# According to shared MIME-info database also tabulator character instead of space character and 12*ae316d1dSXin LI# by TrID minus character after space character 1340427ccaSGordon Tetlow0 search/1 diff\040 diff output text 14*ae316d1dSXin LI# diff output text (strength=40=40+0) after unified diff output (strength=131=38+93) 15*ae316d1dSXin LI#!:strength +0 16b6cee71dSXin LI!:mime text/x-diff 17*ae316d1dSXin LI#!:mime text/x-patch 18*ae316d1dSXin LI!:ext diff/patch 19*ae316d1dSXin LI# no short named pch dif examples found 20*ae316d1dSXin LI#!:ext diff/patch/dif/pch 21*ae316d1dSXin LI# URL: https://en.wikipedia.org/wiki/Diff_utility#Context_format 22*ae316d1dSXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/diff-context.trid.xml 23*ae316d1dSXin LI# Note: called "context diff output" by TrID 24*ae316d1dSXin LI# and "Differences between files" by shared MIME-info database from freedesktop.org 2543a5ec4eSXin LI0 search/1 ***\040 26*ae316d1dSXin LI# context diff output text (strength=42=38+4) before 27*ae316d1dSXin LI# C source (strength=41,39,37) exported SGML document (strength=39,28) 28*ae316d1dSXin LI!:strength +4 2943a5ec4eSXin LI>&0 search/1024 \n---\040 context diff output text 30b6cee71dSXin LI!:mime text/x-diff 31*ae316d1dSXin LI#!:mime text/x-patch 32*ae316d1dSXin LI!:ext diff/patch 33*ae316d1dSXin LI# no short named pch dif examples found 34*ae316d1dSXin LI#!:ext diff/patch/dif/pch 3540427ccaSGordon Tetlow0 search/1 Only\040in\040 diff output text 36*ae316d1dSXin LI# diff output text output text (strength=38=38+0) after unified diff output (strength=131=38+93) 37*ae316d1dSXin LI#!:strength +0 38b6cee71dSXin LI!:mime text/x-diff 39*ae316d1dSXin LI#!:mime text/x-patch 40*ae316d1dSXin LI!:ext diff 4140427ccaSGordon Tetlow0 search/1 Common\040subdirectories:\040 diff output text 42b6cee71dSXin LI!:mime text/x-diff 43b6cee71dSXin LI 44*ae316d1dSXin LI# URL: https://en.wikipedia.org/wiki/Diff#Extensions 45*ae316d1dSXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/diff-rcs.trid.xml 46*ae316d1dSXin LI# Note: called "RCS/CVS diff output" by TrID 47*ae316d1dSXin LI# and "Differences between files" by shared MIME-info database from freedesktop.org 48b6cee71dSXin LI0 search/1 Index: RCS/CVS diff output text 49*ae316d1dSXin LI# RCS/CVS diff output text (strength=36=36+0) after unified diff output (strength=131=38+93) 50*ae316d1dSXin LI#!:strength +0 51b6cee71dSXin LI!:mime text/x-diff 52*ae316d1dSXin LI#!:mime text/x-patch 53*ae316d1dSXin LI!:ext diff/patch 54b6cee71dSXin LI 55b6cee71dSXin LI# bsdiff: file(1) magic for bsdiff(1) output 56*ae316d1dSXin LI# Update: Joerg Jenderek 57*ae316d1dSXin LI# URL: http://www.daemonology.net/bsdiff/ 58*ae316d1dSXin LI# Reference: https://github.com/cperciva/bsdiff/blob/master/bsdiff-ra/FORMAT 59*ae316d1dSXin LI# http://mark0.net/download/triddefs_xml.7z/defs/b/bsdiff.trid.xml 60*ae316d1dSXin LI# Note: called "bsdiff patch" by TrID and and "BSDIFF" version 4.0 by DROID via PUID fmt/439 and 61*ae316d1dSXin LI# "Binary differences between files" by shared MIME-info database from freedesktop.org 62*ae316d1dSXin LI0 string/b BSDIFF40 63*ae316d1dSXin LI# skip DROID fmt-439-signature-id-672.bsdiff with invalid new file segment length 0 64*ae316d1dSXin LI>16 long !0 bsdiff(1) patch file 65*ae316d1dSXin LI#!:mime application/octet-stream 66*ae316d1dSXin LI!:mime application/x-bsdiff 67*ae316d1dSXin LI!:ext bsdiff 68*ae316d1dSXin LI# new file length 69*ae316d1dSXin LI#>>8 lequad x \b, new length %lld 70*ae316d1dSXin LI# new file segment length 71*ae316d1dSXin LI#>>16 lelong x \b, new segment length %d 72*ae316d1dSXin LI# compressed header block length 73*ae316d1dSXin LI#>>20 lelong !0 \b, compressed header length %d 74*ae316d1dSXin LI# patch data block length 75*ae316d1dSXin LI#>>24 lequad x \b, data length %lld 76*ae316d1dSXin LI# look for bzip data by ./compress after message with 1 space at end 77*ae316d1dSXin LI>>0x20 indirect x \b, at 0x20 78b6cee71dSXin LI 79*ae316d1dSXin LI# From: Joerg Jenderek 80*ae316d1dSXin LI# URL: https://www.chromium.org/developers/design-documents/software-updates-courgette/ 81*ae316d1dSXin LI# Reference: https://github.com/adobe/chromium/blob/master/courgette/third_party/bsdiff.h 82*ae316d1dSXin LI# http://mark0.net/download/triddefs_xml.7z/defs/b/bsdiff-chrome.trid.xml 83*ae316d1dSXin LI# Note: called "Courgette Binary Diff output" by TrID 84*ae316d1dSXin LI# the Courgette bsdiff tool use a total different file format compared with BSD variant from Colin Percival 85*ae316d1dSXin LI0 string/b GBSDIF42 Courgette binary diff output 86*ae316d1dSXin LI#!:mime application/octet-stream 87*ae316d1dSXin LI!:mime application/x-patch 88*ae316d1dSXin LI!:ext patch/bsdiff 89*ae316d1dSXin LI# slen; length of the file to be patched 90*ae316d1dSXin LI#>8 ubelong x \b, source length %u 91*ae316d1dSXin LI# scrc32; CRC32 of the file to be patched 92*ae316d1dSXin LI>12 ubelong x \b, crc %#8.8x 93*ae316d1dSXin LI# dlen; length of the result file 94*ae316d1dSXin LI#>16 ubelong x \b, result length %u 95*ae316d1dSXin LI# cblen; length of the control block 96*ae316d1dSXin LI#>20 ubelong x \b, control length %u 97*ae316d1dSXin LI# difflen; length of the diff block 98*ae316d1dSXin LI#>24 ubelong x \b, patch length %u 99*ae316d1dSXin LI# extralen; length of the extra block 100*ae316d1dSXin LI#>28 ubelong x \b, extra length %u 101b6cee71dSXin LI 102b6cee71dSXin LI# unified diff 103*ae316d1dSXin LI# URL: http://fileformats.archiveteam.org/wiki/Unified_diff 104*ae316d1dSXin LI# https://en.wikipedia.org/wiki/Diff_utility#Unified_format 105*ae316d1dSXin LI# Reference: https://www.artima.com/weblogs/viewpost.jsp?thread=164293 106*ae316d1dSXin LI# http://mark0.net/download/triddefs_xml.7z/defs/d/diff-unified.trid.xml 107*ae316d1dSXin LI# Note: called "unified diff output" by TrID and 108*ae316d1dSXin LI# "Differences between files" by shared MIME-info database from freedesktop.org 109*ae316d1dSXin LI# use b flag to forces the test to be done for binary files (non ASCII text like with Ctrl-D Ctrl-V Ctrl-Z) 110*ae316d1dSXin LI0 search/4096/b ---\040 111*ae316d1dSXin LI!:strength + 93 112*ae316d1dSXin LI>0 use diff-unified 113*ae316d1dSXin LI# most samples are just pure ASCII text like: ShellR64.patch 114*ae316d1dSXin LI0 search/11054 ---\040 115*ae316d1dSXin LI# unified diff (strength=131=38+93) before 116*ae316d1dSXin LI# HTML document text (strength=170,90,71,53,52,51,49) POSIX shell script (fix-qt5.6-build.patch strength=130 ./commands) 117*ae316d1dSXin LI# JavaScript source (strength=112,84,81,80,79,78,72,69) C++ source (strength=71,70,69,68,67,54), 118*ae316d1dSXin LI# Python script (strength=69,67,63,60,58,57,56,54,52,37)LaTeX document text (strength=62,56,55,51,43) 119*ae316d1dSXin LI# TeX document (strength=51,38) C source (strength=41,39,37) 120*ae316d1dSXin LI# exported SGML document (strength=39,28) diff output text (strength=38=38+0) 121*ae316d1dSXin LI# Pascal source (strength=37) RCS/CVS diff (strength=36=36+0), 122*ae316d1dSXin LI# Algol 68 source (strength=?) CSV ASCII text (strength=?) 123*ae316d1dSXin LI!:strength + 93 124*ae316d1dSXin LI>0 use diff-unified 125*ae316d1dSXin LI# check for 3 characteristic lines of unified diff 126*ae316d1dSXin LI0 name diff-unified 127*ae316d1dSXin LI>0 search/11084 +++\040 128*ae316d1dSXin LI>>&0 search/1024 \n 129*ae316d1dSXin LI# at signs line sometimes other (with 2 space chars before) like: indent-header.patch 130*ae316d1dSXin LI>>>&0 search/2 @@\040- unified diff output text 131b6cee71dSXin LI!:mime text/x-diff 132*ae316d1dSXin LI#!:mime text/x-patch 133*ae316d1dSXin LI# https://file-extension.net/seeker/file_extension_dif file_extension_pch file_extension_rej 134*ae316d1dSXin LI!:ext diff/patch/dif/pch/rej 135*ae316d1dSXin LI# GRR: mainly for debugging purpose for variants with text before real diff output 136*ae316d1dSXin LI>>>>0 string !---\040 137*ae316d1dSXin LI>>>>>0 string x \b, 1st line "%s" 138*ae316d1dSXin LI>>>>>>&1 string x \b, 2nd line "%s" 139*ae316d1dSXin LI>>>>>>>&1 string x \b, 3rd line "%s" 140b6cee71dSXin LI 141b6cee71dSXin LI# librsync -- the library for network deltas 142b6cee71dSXin LI# 143b6cee71dSXin LI# Copyright (C) 2001 by Martin Pool. You may do whatever you want with 144b6cee71dSXin LI# this file. 145b6cee71dSXin LI# 146b6cee71dSXin LI0 belong 0x72730236 rdiff network-delta data 147b6cee71dSXin LI 148b6cee71dSXin LI0 belong 0x72730136 rdiff network-delta signature data 149b6cee71dSXin LI>4 belong x (block length=%d, 150b6cee71dSXin LI>8 belong x signature strength=%d) 151