diffsitter
diffsitter copied to clipboard
Add example usage with git difftool.
Shamelessly stolen from: https://github.com/wilfred/difftastic#dogfooding
Here's an example with https://github.com/hrkfdn/ncspot/ adding a non-semantic diff:
randall@penguin ~/c/ncspot master ⁝ ✱ ?
❯ git difftool [21:16:37]
/tmp/randall/LS3cZU_main.rs -> src/main.rs
==========================================
randall@penguin ~/c/ncspot master ⁝ ✱ ?
❯ git diff [21:16:40]
diff --git i/src/main.rs w/src/main.rs
index d658e89..0de8190 100644
--- i/src/main.rs
+++ w/src/main.rs
@@ -174,8 +174,11 @@ fn main() {
let mut credentials = {
let cached_credentials = cache.credentials();
match cached_credentials {
+
Some(c) => {
- info!("Using cached credentials");
+ info!(
+ "Using cached credentials"
+ );
c
}
None => credentials_prompt(None),
And another one with a rename:
randall@penguin ~/c/ncspot master ⁝ ✱ ?
❯ git difftool [21:19:16]
/tmp/randall/h2FgKg_main.rs -> src/main.rs
==========================================
174 - 175:
----------
- let cached_credentials = cache.credentials();
- match cached_credentials {
174 - 175:
----------
+ let cached_credential = cache.credentials();
+ match cached_credential {
randall@penguin ~/c/ncspot master ⁝ ✱ ?
❯ git diff [21:19:18]
diff --git i/src/main.rs w/src/main.rs
index d658e89..9e9911f 100644
--- i/src/main.rs
+++ w/src/main.rs
@@ -172,8 +172,8 @@ fn main() {
let cache = Cache::new(config::cache_path("librespot"), true);
let mut credentials = {
- let cached_credentials = cache.credentials();
- match cached_credentials {
+ let cached_credential = cache.credentials();
+ match cached_credential {
Some(c) => {
info!("Using cached credentials");
c
Nice, tried it out and it seems to work fine. Probably easier/cleaner than my little script here: https://github.com/afnanenayet/diffsitter/blob/main/assets/git-diffsitter
Fixes #155
When I run git difftool
in my repo with a markdown file, it produces Error: Unsupported filetype "md"
- is this expected?
I'm thinking that your script may be useful with a .gitattributes file with supported file types listed like this. That way it only operates on file types that are supported, plus it then works with plain riff. The disadvantage is that you can't get an apply-able diff always...
Ultimately, it would be nice if diffsitter would handle unknown files and show a non-semantic diff. But this is beyond the scope of this. I have opened https://github.com/afnanenayet/diffsitter/issues/160
With an intermediary script I guess it could achieve naively this way: diffsitter "$@" || diff "$@"
.
When I run
git difftool
in my repo with a markdown file, it producesError: Unsupported filetype "md"
- is this expected?
According to the readme in repo, it doesn't support markdown.
diffsitter supports the following languages:
Bash C# C++ CSS Go Java OCaml PHP Python Ruby Rust
There are some comments below mentioning the need to handle unsupported file type more graceful.
We gracefully handle unsupported filetypes now that #212 has been merged
Does this supersede #208 ?
No, I think I wanted to make the git experience more ergonomic so I never ended up merging that PR.