From: Michael Horowitz <hidden> Date: 2016-06-15 22:52:42
Hello all,
I have been unable to find a solution to this, so I figured I would
post to this list...
I am trying to make an easy command to let me look at the last diff to
a specified file, either plain or with a diff tool, such as vimdiff.
This is the last actual change, not just HEAD^, because the file may
not have changed in many commits.
I was able to make the following 2 aliases, which work perfectly
except for one problem...
ldiff = "!git diff `git rev-list --reverse -n 2 HEAD -- $1` -- $1"
ldifft = "!git difftool `git rev-list --reverse -n 2 HEAD -- $1` -- $1"
The problem is the limitation that shell commands are always executed
at the top-level directory of the repository. Normally I am in a
deeply nested directory, so if I specify the file name in that
directory, it doesn't work. Having to specify the full path relative
to the top level makes these aliases more cumbersome to use than their
worth.
Is there a way to get around this, or even a completely different way
to do this that I am missing? I want to avoid making a completely
separate shell script.
Thanks,
Mike
I don't know that you can do something equivalent with difftool. I
suppose you could do the above with "GIT_EXTERNAL_DIFF=<some difftool
wrapper> git ldiff", but that's not very helpful.
I don't know that you can do something equivalent with difftool. I
suppose you could do the above with "GIT_EXTERNAL_DIFF=<some difftool
wrapper> git ldiff", but that's not very helpful.
Perhaps we would want a convenient way for "log -p" or "show -p" to drive
difftool as a backend?
I think that's exactly it. difftool wraps diff; a log equivalent
would be quite helpful.
One idea is for difftool to learn a "--log" option to make it wrap log
instead. I don't know if a diff-like command having a "--log" option
is ideal from a consistency-of-user-interface POV so I'm open to
ideas. It is convenient, though. It does seem like difftool would be
a good place to expose this feature.
I'd be interested in the "teach log / show -p about GIT_EXTERNAL_DIFF"
route, if that sounds like a good idea.
--
David
From: Michael Horowitz <hidden> Date: 2016-06-15 22:52:42
The log operation does seem to make the most sense as the mechanism to
search for the results. Making it work with difftool would work...
Not sure if "--log" to difftool or some other options as suggested in
the other thread would be most consistent UI-wise as stated, but
either would work for me.
On a separate note, some environment variable like GIT_PREFIX with the
CWD would make the alias functionality more flexible.
Mike
On Thu, Dec 29, 2011 at 8:59 PM, David Aguilar [off-list ref] wrote:
On Thu, Dec 29, 2011 at 9:08 AM, Dave Borowitz [off-list ref] wrote:
quoted
On Wed, Dec 28, 2011 at 17:27, Michael Horowitz
[off-list ref] wrote:
I don't know that you can do something equivalent with difftool. I
suppose you could do the above with "GIT_EXTERNAL_DIFF=<some difftool
wrapper> git ldiff", but that's not very helpful.
Perhaps we would want a convenient way for "log -p" or "show -p" to drive
difftool as a backend?
I think that's exactly it. difftool wraps diff; a log equivalent
would be quite helpful.
One idea is for difftool to learn a "--log" option to make it wrap log
instead. I don't know if a diff-like command having a "--log" option
is ideal from a consistency-of-user-interface POV so I'm open to
ideas. It is convenient, though. It does seem like difftool would be
a good place to expose this feature.
I'd be interested in the "teach log / show -p about GIT_EXTERNAL_DIFF"
route, if that sounds like a good idea.
--
David
From: Jakub Narebski <hidden> Date: 2016-06-15 22:52:42
Michael Horowitz [off-list ref] writes:
The log operation does seem to make the most sense as the mechanism to
search for the results. Making it work with difftool would work...
Not sure if "--log" to difftool or some other options as suggested in
the other thread would be most consistent UI-wise as stated, but
either would work for me.
On a separate note, some environment variable like GIT_PREFIX with the
CWD would make the alias functionality more flexible.
1f5d271 (setup: Provide GIT_PREFIX to built-ins, 2011-05-25) is
present in v1.7.7; 7cf16a1 (handle_alias: provide GIT_PREFIX to
!alias, 2011-04-27) is in 1.7.6
--
Jakub Narebski
From: Michael Horowitz <hidden> Date: 2016-06-15 22:52:42
Nice, works perfectly! Didn't notice that was there, guess last time
I looked, I was using an older version. I see it is in the git config
man page and all now.
Thanks,
Mike
On Sat, Dec 31, 2011 at 6:30 PM, Jakub Narebski [off-list ref] wrote:
Michael Horowitz [off-list ref] writes:
quoted
The log operation does seem to make the most sense as the mechanism to
search for the results. Making it work with difftool would work...
Not sure if "--log" to difftool or some other options as suggested in
the other thread would be most consistent UI-wise as stated, but
either would work for me.
On a separate note, some environment variable like GIT_PREFIX with the
CWD would make the alias functionality more flexible.
1f5d271 (setup: Provide GIT_PREFIX to built-ins, 2011-05-25) is
present in v1.7.7; 7cf16a1 (handle_alias: provide GIT_PREFIX to
!alias, 2011-04-27) is in 1.7.6
--
Jakub Narebski