{"id":13395469,"url":"https://github.com/Wilfred/difftastic","last_synced_at":"2025-03-13T21:31:43.518Z","repository":{"id":37387507,"uuid":"162276894","full_name":"Wilfred/difftastic","owner":"Wilfred","description":"a structural diff that understands syntax 🟥🟩","archived":false,"fork":false,"pushed_at":"2024-04-10T13:45:53.000Z","size":1570248,"stargazers_count":19376,"open_issues_count":196,"forks_count":300,"subscribers_count":58,"default_branch":"master","last_synced_at":"2024-04-14T10:16:07.048Z","etag":null,"topics":["diff","tree-sitter"],"latest_commit_sha":null,"homepage":"https://difftastic.wilfred.me.uk/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Wilfred.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-12-18T11:19:45.000Z","updated_at":"2024-05-11T23:40:10.913Z","dependencies_parsed_at":"2022-07-10T14:01:05.856Z","dependency_job_id":"db40450e-2d4d-4ddc-818b-f5b4d4580d03","html_url":"https://github.com/Wilfred/difftastic","commit_stats":{"total_commits":11158,"total_committers":348,"mean_commits":32.0632183908046,"dds":0.8052518372468185,"last_synced_commit":"1e9f4376887a01817bcedfc56a03d3eb4ab14a9d"},"previous_names":[],"tags_count":72,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wilfred%2Fdifftastic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wilfred%2Fdifftastic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wilfred%2Fdifftastic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wilfred%2Fdifftastic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wilfred","download_url":"https://codeload.github.com/Wilfred/difftastic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221411584,"owners_count":16815696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diff","tree-sitter"],"created_at":"2024-07-30T17:02:00.736Z","updated_at":"2025-03-13T21:31:43.493Z","avatar_url":"https://github.com/Wilfred.png","language":"Rust","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"#readme\"\u003e\u003cimg src=\"img/logo.png\" alt=\"it's difftastic!\"/\u003e\u003c/a\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://difftastic.wilfred.me.uk/introduction.html\"\u003e\u003cimg src=\"https://img.shields.io/badge/manual-en-brightgreen?style=flat-square\" alt=\"English manual\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://difftastic.wilfred.me.uk/zh-CN/\"\u003e\u003cimg src=\"https://img.shields.io/badge/manual-zh--CN-brightgreen?style=flat-square\" alt=\"Chinese manual\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://crates.io/crates/difftastic\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/difftastic.svg?style=flat-square\" alt=\"crates.io\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/Wilfred/difftastic\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/github/Wilfred/difftastic?style=flat-square\u0026token=dZzAZtQT2S\" alt=\"codecov.io\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nDifftastic is a structural diff tool that compares files based on\ntheir syntax.\n\n**For installation instructions, see\n[Installation](https://difftastic.wilfred.me.uk/installation.html) in\n[the manual](http://difftastic.wilfred.me.uk/).**\n\n## Basic Example\n\n![Screenshot of difftastic and JS](img/js.png)\n\nIn this JavaScript example, we can see:\n\n(1) Difftastic understands nesting. It highlights the matching `{` and\n`}`, but understands that `foo()` hasn't changed despite the leading\nwhitespace.\n\n(2) Difftastic understands which lines should be aligned. It's aligned\n`bar(1)` on the left with `bar(2)` on the right, even though the\ntextual content isn't identical.\n\n(3) Difftastic understands that line-wrapping isn't\nmeaningful. `\"eric\"` is now on a new line, but it hasn't changed.\n\n## One Minute Demo\n\n[![asciicast](https://asciinema.org/a/480875.svg)](https://asciinema.org/a/480875)\n\nThis one minute screencast demonstrates difftastic usage with both\nstandalone files and git.\n\n## Languages\n\nDifftastic supports over 30 programming languages, see [the\nmanual](https://difftastic.wilfred.me.uk/languages_supported.html) for the full list.\n\nIf a file has an unrecognised extension, difftastic uses a\ntextual diff with word highlighting.\n\n## Known Issues\n\nPerformance. Difftastic scales relatively poorly on files with a large\nnumber of changes, and can use a lot of memory.\n\nDisplay. Difftastic has a side-by-side display which usually works well, but can\nbe confusing.\n\nRobustness. Difftastic regularly has releases that fix crashes.\n\n## Non-goals\n\nPatching. Difftastic output is intended for human consumption, and it\ndoes not generate patches that you can apply later. Use `diff` if you\nneed a patch.\n\n(Patch files are also line-oriented, which is too limited for\ndifftastic. Difftastic might find additions and removals on the same\nline, and it tracks the relationship between line numbers in the old\nand new file.)\n\nMerging. AST merging is a hard problem that difftastic does not\naddress.\n\n## FAQ\n\n### Isn't this basically `--word-diff --ignore-all-space`?\n\nWord diffing [can't do\nthis](https://twitter.com/_wilfredh/status/1510139929971421191/photo/1).\n\nDifftastic parses your code. It understands when whitespace matters,\nsuch as inside string literals or languages like Python. It understands\nthat `x-1` is three tokens in JS but one token in Lisp.\n\n### Can I use difftastic with git?\n\nYou can! The difftastic manual [includes instructions for git\nusage](https://difftastic.wilfred.me.uk/git.html). You can also use it\n[with mercurial](https://difftastic.wilfred.me.uk/mercurial.html).\n\nIf you're a magit user, check out [this blog\npost](https://tsdh.org/posts/2022-08-01-difftastic-diffing-with-magit.html)\nshowing one way to use difftastic with magit.\n\n### Does difftastic integrate with my favourite tool?\n\nProbably not. Difftastic is young. Consider writing a plugin for your\nfavourite tool, and I will link it in the README!\n\n### Can difftastic help me with merge conflicts?\n\nYes! As of version 0.50, difftastic understands merge conflict markers\n(i.e. `\u003c\u003c\u003c\u003c\u003c\u003c\u003c`, `=======` and `\u003e\u003e\u003e\u003e\u003e\u003e\u003e`).\n\nPass your file with conflicts as a single argument to\ndifftastic. Difftastic will construct the two conflicting files and\ndiff those.\n\n```\n$ difft file_with_conflicts.js\n```\n\n### Can difftastic do merges?\n\nNo. AST merging is a hard problem that difftastic does not address.\n\nAST diffing is a lossy process from the perspective of a text\ndiff. Difftastic will ignore whitespace that isn't syntactically\nsignificant, but merging requires tracking whitespace.\n\nThe [mergiraf](https://mergiraf.org/) tool does offer merges based on\na tree-sitter AST however.\n\n### Can difftastic ignore reordering?\n\nNo. Difftastic always considers order to be important, so diffing\ne.g. `set(1, 2)` and `set(2, 1)` will show changes.\n\nIf you're diffing JSON, consider sorting the keys before passing them\nto difftastic.\n\n```\n$ difft \u003c(jq --sort-keys \u003c file_1.json) \u003c(jq --sort-keys \u003c file_2.json)\n```\n\nSee also [Tricky Cases: Unordered Data\nTypes](https://difftastic.wilfred.me.uk/tricky_cases.html#unordered-data-types)\nin the manual.\n\n### Can I use difftastic to check for syntactic changes without diffing?\n\nYes. Difftastic can check if the two files have the same AST, without\ncalculating a diff. This is much faster than normal diffing, and\nuseful for building tools that check for changes.\n\nFor example:\n\n```\n$ difft --check-only --exit-code before.js after.js\n```\n\nThis will set the exit code to 0 if there are no syntactic changes, or\n1 if there are changes found.\n\n### Why aren't colours appearing in my terminal?\n\nDifftastic uses ANSI bright colours by default, but some terminal\nthemes show bright colours as grey. Solarized is a popular theme that\ndoes this.\n\nIf you're a Solarized user, use `export DFT_BACKGROUND=light` to\ndisable bright colours, or try a different terminal colour scheme.\n\n### How does it work?\n\nDifftastic treats structural diffing as a graph problem, and uses\nDijkstra's algorithm.\n\nMy [blog\npost](https://www.wilfred.me.uk/blog/2022/09/06/difftastic-the-fantastic-diff/)\ndescribes the design, and there is also an [internals section in the\nmanual](https://difftastic.wilfred.me.uk/diffing.html).\n\n## Translation\n\n+ [Chinese](./translation/zh-CN/README-zh-CN.md)\n\n## License\n\nDifftastic is open source under the MIT license, see LICENSE for more\ndetails.\n\nThis repository also includes tree-sitter parsers by other authors in\nthe `vendored_parsers/` directory. These are a mix of the MIT license and the\nApache license. See `vendored_parsers/*/LICENSE` for more details.\n\nFiles in `sample_files/` are also under the MIT license unless stated\notherwise in their header.\n","funding_links":[],"categories":["Rust","Development tools","C","others","Version control","Weapons","Tools","\u003ca name=\"diff\"\u003e\u003c/a\u003eDiff","Source Code","\u003ca name=\"Rust\"\u003e\u003c/a\u003eRust","Dev-Utilities","Git Interfaces","Applications","Other"],"sub_categories":["Workflow Automation","Tools","Rust","Semantic Diffs","System tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWilfred%2Fdifftastic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWilfred%2Fdifftastic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWilfred%2Fdifftastic/lists"}