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