summaryrefslogtreecommitdiffstats
path: root/difft.1.md
blob: fe037b8a5a9da78c2818391a26f60da9550ae4b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
% DIFFT(1)

NAME
====

**difft** - a structural diff tool that understands syntax

SYNOPSIS
========

**difft** \[_OPTIONS_] _OLD-PATH_ _NEW-PATH_

**difft** \[_OPTIONS_] _DIRECTORY-ONE_ _DIRECTORY-TWO_

**difft** \[_OPTIONS_] _FILE-WITH-CONFLICTS_

**difft** **\-\-list-languages**

**difft** **\-\-help**

DESCRIPTION
===========

difftastic (difft) is a CLI diff tool that compares files based on
their syntax, not line-by-line. Difftastic produces accurate diffs
that are easier for humans to read.

OPTIONS
-------

**\-\-background** _BACKGROUND_

: Set the background brightness. Difftastic will prefer brighter colours on dark
  backgrounds.

**\-\-byte-limit** _LIMIT_

: Use a text diff if either input file exceeds this size.

**\-\-check-only**

: Report whether there are any changes, but don't calculate them. Much faster.

**\-\-color** _WHEN_

: When to use color output.

**\-\-context** _LINES_

: The number of contextual lines to show around changed lines.

**\-\-display** _MODE_

: Display mode for showing results.

    _side-by-side_: Display the before file and the after file in two separate columns, with
    line numbers aligned according to unchanged content. If a change is exclusively
    additions or exclusively removals, use a single column.

    _side-by-side-show-both_: The same as _side-by-side_, but always uses two columns.

    _inline_: A single column display, closer to traditional diff display.

    _json_: Output the results as a machine-readable JSON array with an element per file.

**\-\-exit-code**

: Set the exit code to 1 if there are syntactic changes in any files. For files where
  there is no detected language (e.g. unsupported language or binary files), sets the exit
  code if there are any byte changes.

**\-\-graph-limit** _LIMIT_

: Use a text diff if the structural graph exceed this number of nodes in memory.

**-h, \-\-help**

: Print help information.

**\-\-ignore-comments**

: Don't consider comments when diffing.

**\-\-list-languages**

: Print the all the languages supported by difftastic, along with their extensions.

**\-\-missing-as-empty**

: Treat paths that don't exist as equivalent to an empty file. Only applies when diffing
  files, not directories.

**\-\-override** _GLOB:NAME_

: Associate this glob pattern with this language, overriding normal language detection.
  For example:

    $ difft \-\-override='*.c:C++' old.c new.c

    See **\-\-list-languages** for the list of language names. Language names are matched case
    insensitively. Overrides may also specify the language _"text"_ to treat a file as plain
    text.

    This argument may be given more than once. For example:

    $ difft \-\-override='CustomFile:json' \-\-override='*.c:text' old.c new.c

    To configure multiple overrides using environment variables, difftastic also accepts
    **DFT_OVERRIDE_1** up to **DFT_OVERRIDE_9**.

    $ export DFT_OVERRIDE='CustomFile:json'
    $ export DFT_OVERRIDE_1='*.c:text'
    $ export DFT_OVERRIDE_2='*.js:javascript jsx'

    When multiple overrides are specified, the first matching override wins.

**\-\-parse-error-limit** _LIMIT_

: Use a text diff if the number of parse errors exceeds this value.

**\-\-skip-unchanged**

: Don't display anything if a file is unchanged.

**\-\-sort-paths**

: When diffing a directory, output the results sorted by path. This is slower.

**\-\-strip-cr**

: Remove any carriage return characters before diffing. This can be helpful when dealing
  with files on Windows that contain CRLF, i.e. **\r\n**.

**\-\-syntax-highlight** _on/off_

: Enable or disable syntax highlighting.

**\-\-tab-width** _NUMSPACES_

: Treat a tab as this many spaces.

**-V, \-\-version**

: Print version information.

**\-\-width** _COLUMNS_

: Use this many columns when calculating line wrapping. If not specified, difftastic will
  detect the terminal width.

DEBUG OPTIONS
-------------

**\-\-dump-syntax** _PATH_

: Parse a single file with tree-sitter and display the difftastic syntax tree.

**\-\-dump-ts** _PATH_

: Parse a single file with tree-sitter and display the tree-sitter parse
  tree.

MANUAL
======

A full HTML manual is available at <https://difftastic.wilfred.me.uk/introduction>.

BUGS
====

See GitHub issues at <https://github.com/Wilfred/difftastic/issues>.

AUTHOR
======

Wilfred Hughes <me@wilfred.me.uk>