Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
βCITATION.cff file
Found CITATION.cff file -
βcodemeta.json file
Found codemeta.json file -
β.zenodo.json file
Found .zenodo.json file -
βDOI references
-
βAcademic publication links
-
βCommitters with academic emails
7 of 440 committers (1.6%) from academic institutions -
βInstitutional organization owner
-
βJOSS paper metadata
-
βScientific vocabulary similarity
Low similarity (12.2%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
a structural diff that understands syntax π₯π©
Basic Info
- Host: GitHub
- Owner: Wilfred
- License: mit
- Language: Rust
- Default Branch: master
- Homepage: https://difftastic.wilfred.me.uk/
- Size: 1.58 GB
Statistics
- Stars: 22,854
- Watchers: 62
- Forks: 394
- Open Issues: 241
- Releases: 47
Topics
Metadata Files
README.md
Difftastic is a structural diff tool that compares files based on their syntax.
For installation instructions, see Installation in the manual.
Basic Example

In this JavaScript example, we can see:
(1) Difftastic understands nesting. It highlights the matching { and
}, but understands that foo() hasn't changed despite the leading
whitespace.
(2) Difftastic understands which lines should be aligned. It's aligned
bar(1) on the left with bar(2) on the right, even though the
textual content isn't identical.
(3) Difftastic understands that line-wrapping isn't
meaningful. "eric" is now on a new line, but it hasn't changed.
One Minute Demo
This one minute screencast demonstrates difftastic usage with both standalone files and git.
Languages
Difftastic supports over 30 programming languages, see the manual for the full list.
If a file has an unrecognised extension, difftastic uses a textual diff with word highlighting.
Known Issues
Performance. Difftastic scales relatively poorly on files with a large number of changes, and can use a lot of memory.
Display. Difftastic has a side-by-side display which usually works well, but can be confusing.
Robustness. Difftastic regularly has releases that fix crashes.
Non-goals
Patching. Difftastic output is intended for human consumption, and it
does not generate patches that you can apply later. Use diff if you
need a patch.
(Patch files are also line-oriented, which is too limited for difftastic. Difftastic might find additions and removals on the same line, and it tracks the relationship between line numbers in the old and new file.)
Merging. AST merging is a hard problem that difftastic does not address. You might be interested in the mergiraf tool ("merge giraffe"), which does do AST merging.
FAQ
Isn't this basically --word-diff --ignore-all-space?
Word diffing can't do this.
Difftastic parses your code. It understands when whitespace matters,
such as inside string literals or languages like Python. It understands
that x-1 is three tokens in JS but one token in Lisp.
Can I use difftastic with git?
You can! The difftastic manual includes instructions for git usage. You can also use it with mercurial.
If you're an Emacs user, check out this blog post showing one way to use difftastic with magit, as well as difftastic.el.
Does difftastic integrate with my favourite tool?
Probably not. Difftastic is young. Consider writing a plugin for your favourite tool, and I will link it in the README!
What about parse errors?
By default, difftastic falls back to a line-oriented diff whenever parse errors are encountered.
This is a conservative choice to ensure that difftastic never claims two syntactically different files are the same.
Parse errors can occur if the file uses language features that the parser does not understand, if the language relies on a preprocessor before parsing (e.g. C++), or if the file has genuine syntactic mistakes.
In practice, difftastic virtually always produces a good result when there are a few minor parse errors. Consider allowing a small number of parse errors when using difftastic.
$ export DFT_PARSE_ERROR_LIMIT=20
$ difft foo1.c foo2.c
Can difftastic help me with merge conflicts?
Yes! As of version 0.50, difftastic understands merge conflict markers
(i.e. <<<<<<<, ======= and >>>>>>>).
Pass your file with conflicts as a single argument to difftastic. Difftastic will construct the two conflicting files and diff those.
$ difft file_with_conflicts.js
Can difftastic do merges?
No. AST merging is a hard problem that difftastic does not address.
AST diffing is a lossy process from the perspective of a text diff. Difftastic will ignore whitespace that isn't syntactically significant, but merging requires tracking whitespace.
The mergiraf tool does offer merges based on a tree-sitter AST however.
Can difftastic ignore reordering?
No. Difftastic always considers order to be important, so diffing
e.g. set(1, 2) and set(2, 1) will show changes.
If you're diffing JSON, consider sorting the keys before passing them to difftastic.
$ difft <(jq --sort-keys < file_1.json) <(jq --sort-keys < file_2.json)
See also Tricky Cases: Unordered Data Types in the manual.
Can I use difftastic to check for syntactic changes without diffing?
Yes. Difftastic can check if the two files have the same AST, without calculating a diff. This is much faster than normal diffing, and useful for building tools that check for changes.
For example:
$ difft --check-only --exit-code before.js after.js
This will set the exit code to 0 if there are no syntactic changes, or 1 if there are changes found.
Why aren't colours appearing in my terminal?
Difftastic uses ANSI bright colours by default, but some terminal themes show bright colours as grey. Solarized is a popular theme that does this.
If you're a Solarized user, use export DFT_BACKGROUND=light to
disable bright colours, or try a different terminal colour scheme.
How does it work?
Difftastic treats structural diffing as a graph problem, and uses Dijkstra's algorithm.
My blog post describes the design, and there is also an internals section in the manual.
Translation
License
Difftastic is open source under the MIT license, see LICENSE for more details.
This repository also includes tree-sitter parsers by other authors in
the vendored_parsers/ directory. These are a mix of the MIT license and the
Apache license. See vendored_parsers/*/LICENSE for more details.
Files in sample_files/ are also under the MIT license unless stated
otherwise in their header.
Owner
- Name: Wilfred Hughes
- Login: Wilfred
- Kind: user
- Location: Bay Area, USA
- Website: https://www.wilfred.me.uk/
- Twitter: _wilfredh
- Repositories: 423
- Profile: https://github.com/Wilfred
PL enthusiast, Emacs addict, and an advocate for human factors.
Citation (CITATION.cff)
cff-version: 1.2.0
title: Difftastic
message: 'To cite difftastic in publications use:'
type: software
authors:
- given-names: Wilfred
family-names: Hughes
email: me@wilfred.me.uk
url: https://github.com/wilfred/difftastic
repository-artifact: https://crates.io/crates/difftastic
abstract: A syntactic diffing tool
keywords:
- diffing
- programming languages
license: MIT
Committers
Last synced: 10 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Wilfred Hughes | me@w****k | 2,819 |
| Max Brunsfeld | m****d@g****m | 2,151 |
| Rick Winfrey | r****y@g****m | 984 |
| Amaan Qureshi | a****2@g****m | 494 |
| joshvera | j****h@j****m | 447 |
| Timothy Clem | t****m@g****m | 343 |
| Rob Rix | r****x@g****m | 289 |
| Kolja Lampe | r****e@g****m | 279 |
| Damien Guard | d****g@g****m | 237 |
| Joran Honig | j****g@g****m | 199 |
| Anantha Kumaran | a****n@g****m | 183 |
| Antonio de Jesus Ochoa Solano | a****o@g****m | 177 |
| ganezdragon | g****3@g****m | 169 |
| 6cdh | c****h@g****m | 161 |
| sogaiu | 9****2 | 159 |
| Nikolaj Sidorenco | n****6@h****m | 150 |
| fwcd | f****l@g****m | 150 |
| Ayman Nadeem | a****m@g****m | 149 |
| Alexandre Muller | m****r@o****m | 148 |
| Alex Pinkus | a****s@g****m | 131 |
| Yuya Nishihara | y****a@t****g | 125 |
| mhoffm | m****m@p****e | 120 |
| Uy Ha | h****y@g****m | 111 |
| Maksim Novikov | m****k@g****m | 110 |
| Azganoth | i****r@g****m | 109 |
| Torsten Schmits | t****s@g****m | 108 |
| Patrick FΓΆrster | p****r | 104 |
| Eugene Yokota | e****n@g****m | 97 |
| Stephan Seitz | s****z@f****e | 93 |
| Jonathan Arnett | j****0@g****m | 88 |
| and 410 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 344
- Total pull requests: 142
- Average time to close issues: 3 months
- Average time to close pull requests: about 2 months
- Total issue authors: 221
- Total pull request authors: 94
- Average comments per issue: 1.92
- Average comments per pull request: 2.25
- Merged pull requests: 68
- Bot issues: 0
- Bot pull requests: 7
Past Year
- Issues: 75
- Pull requests: 37
- Average time to close issues: 20 days
- Average time to close pull requests: 16 days
- Issue authors: 57
- Pull request authors: 23
- Average comments per issue: 0.65
- Average comments per pull request: 1.19
- Merged pull requests: 18
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- Wilfred (93)
- berrymot (4)
- tomwhoiscontrary (4)
- gthb (3)
- mattpass (3)
- bradzacher (3)
- frontsideair (2)
- tmysik (2)
- iacore (2)
- Freaksed (2)
- Krinkle (2)
- arbrauns (2)
- vi (2)
- olivergondza (2)
- nimrodkor (2)
Pull Request Authors
- yuja (9)
- arbrauns (7)
- dependabot[bot] (7)
- MarcelCoding (6)
- nimrodkor (5)
- yedayak (4)
- Kissaki (4)
- yusancky (4)
- grunweg (4)
- crbelaus (4)
- Pi-Cla (4)
- bryceberger (4)
- sesse (3)
- gthb (3)
- egrieco (3)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 5
-
Total downloads:
- homebrew 867 last-month
- cargo 162,264 total
- Total docker downloads: 23,284,192
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 42
(may contain duplicates) - Total versions: 117
- Total maintainers: 2
proxy.golang.org: github.com/Wilfred/difftastic
- Homepage: https://github.com/Wilfred/difftastic
- Documentation: https://pkg.go.dev/github.com/Wilfred/difftastic#section-documentation
- License: MIT
Rankings
proxy.golang.org: github.com/wilfred/difftastic
- Homepage: https://github.com/wilfred/difftastic
- Documentation: https://pkg.go.dev/github.com/wilfred/difftastic#section-documentation
- License: MIT
Rankings
formulae.brew.sh: difftastic
Diff that understands syntax
- Homepage: https://github.com/Wilfred/difftastic
- License: MIT
-
Latest release: 0.64.0
published 8 months ago
Rankings
crates.io: difftastic
A structural diff that understands syntax.
- Homepage: http://difftastic.wilfred.me.uk/
- Documentation: https://docs.rs/difftastic/
- License: MIT
-
Latest release: 0.64.0
published 8 months ago
Rankings
Maintainers (1)
crates.io: difftastic-oc
A syntactic diff
- Homepage: http://difftastic.wilfred.me.uk/
- Documentation: https://docs.rs/difftastic-oc/
- License: MIT
-
Latest release: 0.23.0
published over 3 years ago
