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

--since flag fails when git is configured with a different diff tool #1387

Open
appleton opened this issue May 22, 2023 · 4 comments
Open

--since flag fails when git is configured with a different diff tool #1387

appleton opened this issue May 22, 2023 · 4 comments

Comments

@appleton
Copy link

I have Difftastic configured as my default git diff tool with this gitconfig entry:

[diff]
	external = difft

This causes git diff REF to output in a different format which in turn breaks the --since flag functionality which relies on the output to be in an expected format.

I was hoping git diff might have a flag to force the default diff tool for a single command but as far as I can tell that isn't the case.

One solution for me would be to just revert to using the regular git diff output but I'd rather not do this so I'm opening an issue hoping you have a better idea. I wonder if prioritising #1337 would make this issue go away or if that would still need to start with parsing a git diff output?

@appleton appleton changed the title --since flag fails when git is configured with a different diff tool --since flag fails when git is configured with a different diff tool May 22, 2023
@mbj
Copy link
Owner

mbj commented May 22, 2023

Interesting one.

So I do not think #1337 will fix it, mutant first has to discover the changed lines relative to the provided git reference before than using the AST diff. Else it would have to parse "way to much" AST which would be to slow.

I never was happy to parse the line information out of the diff headers (mutant ignores the body), and wish I would find a more native command to display the "changed line ranges only".

So I see 2 path:

  1. Make mutant (likely via environment variables) force to use the build in diff.
  2. Finally find a git command that only outputs the touched line ranges, supressing the regular unified diff output.

I'd prefer 2) as this would be faster and more stable. But I suspect there is an easy 1) also. I'll look into it.

@appleton
Copy link
Author

I was unable to find a solution to option 1, although I'm sure you're better placed to figure it out than me. It seems that git doesn't allow disabling a custom tool via env var.

What it does allow is setting a custom diff tool via env var though and this has let me fix my workflow. I have removed the diff configuration from my gitconfig and am instead using direnv (which I already use for other stuff) to set GIT_EXTERNAL_DIFF=difft for my home directory and all subdirectories. It doesn't quite resolve this issue for another person who might run into it, but maybe it can give you a clue?

@mbj
Copy link
Owner

mbj commented May 22, 2023

What it does allow is setting a custom diff tool via env var though and this has let me fix my workflow.

I think mutant could set the external diff tool to the internal one, untested.

@dgollahon
Copy link
Sponsor Collaborator

Another option could maybe be to use —name-only and maybe a diff filter and then run the AST diff. That way you wouldn’t have to parse the output of the git diff. I actually also use a different git tool (delta) but, as far as i can tell, it just happens to work. There is a chance it only changes the format when it’s invoked directly though and reverts to the normal format when you shell out to it.

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

No branches or pull requests

3 participants