-
Notifications
You must be signed in to change notification settings - Fork 344
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
feat: use $MERGED if present in environment, as the display path #734
Conversation
The resolution of Wilfred#620 does not help for the case of git invocations comparing two git commits, like `git dft main...` or `git dft branch1...branch2`, because in those cases both the lhs and the rhs path are temporary files, obscuring the real path to the file within git. In those cases, git makes the real path available as the MERGED shell variable, for the purposes of constructing a difftool command line in git configuration. So in Difftastic, let the real path be specified by an environment variable, and suggest populating that with "$MERGED" in the git difftool configuration.
Maybe difftastic should just respect MERGED when invoked from git, rather than expecting a REAL_PATH environment variable? Happy to merge this if you make that change :) |
That's what I tried first, hoping to not need any I renamed it to [difftool "difftastic"]
- cmd = REAL_PATH="$MERGED" difft "$LOCAL" "$REMOTE"
+ cmd = MERGED="$MERGED" difft "$LOCAL" "$REMOTE" That's why I had chosen the different name |
The point is to make the shell variable an environment variable and this is the more explicit way to do that. Thus less likely to cause user confusion about whether/why this is necessary.
Just realized that this would be less confusing if the |
This comment was marked as outdated.
This comment was marked as outdated.
I realized that this was using $MERGED in too specific a case, missing the cases where a file was removed or added. Probably want $MERGED to be used as the display filename in all cases, if it is present.
I noticed that this was missing the case where a file is removed or added, in the commit span being compared, so lhs or rhs is |
Could you consider merging this (or telling me what I need to do with it first :) ) so that I don't have to maintain a local build for this fix? |
Crikey, difftool is generally not what we want (git doesn't pass rename information), but external diff tools crash unless you're on a recent git version. I've overhauled the git configuration page in the manual, and I think it fixes the issues you've encountered. Let me know if not :) |
Looks like it does! |
In #620 the display path was fixed to be based on the right-hand-side filename in the case that the left-hand-side filename is a git temporary file.
But that does not help for the case of git invocations comparing two git commits, such as:
git dft main...
git dft branch1...branch2
... because, in those cases, both the lhs and the rhs path are git temporary files, obscuring the real path to the file within the git repository.
The same applies if a file is removed or added, in which case one of the paths is a git temporary file and the other is
/dev/null
.In those cases, git makes the real path available as the
MERGED
shell variable, for the purposes of constructing a difftool command line in git configuration.So in Difftastic, let the real path be specified by the
MERGED
environment variable (overriding the lhs and rhs paths), and suggestexport
-ing that into Difftastic's environment in the git difftool configuration.