Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example usage with git difftool. #157

Merged
merged 2 commits into from Dec 27, 2022

Conversation

ClashTheBunny
Copy link
Contributor

@ClashTheBunny
Copy link
Contributor Author

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

@afnanenayet
Copy link
Owner

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

afnanenayet
afnanenayet previously approved these changes Jul 20, 2021
@j-martin
Copy link

Fixes #155

@gakonst
Copy link

gakonst commented Jul 20, 2021

When I run git difftool in my repo with a markdown file, it produces Error: Unsupported filetype "md" - is this expected?

@ClashTheBunny
Copy link
Contributor Author

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...

@j-martin
Copy link

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 #160

With an intermediary script I guess it could achieve naively this way: diffsitter "$@" || diff "$@".

@pakls
Copy link

pakls commented Jul 29, 2021

When I run git difftool in my repo with a markdown file, it produces Error: 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.

@afnanenayet
Copy link
Owner

We gracefully handle unsupported filetypes now that #212 has been merged

@haolly
Copy link

haolly commented Dec 3, 2022

Does this supersede #208 ?

@afnanenayet
Copy link
Owner

No, I think I wanted to make the git experience more ergonomic so I never ended up merging that PR.

@afnanenayet afnanenayet merged commit 78aa3f5 into afnanenayet:main Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants