{"thread":{"id":"29261","subject":"git alias question","startedAt":"2011-12-29T01:27:59Z","lastAt":"2012-01-02T05:57:44Z","messageCount":8,"participants":["Michael Horowitz","Miles Bader","Junio C Hamano","Dave Borowitz","David Aguilar","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"181769","messageId":"CAFLRbopjqW7OEWN4kxy+6Gb828h4zBC_h=4WiP-q1__LeezxUw@mail.gmail.com","threadId":"29261","inReplyTo":null,"subject":"git alias question","fromName":"Michael Horowitz","fromEmail":"michael.horowitz@ieee.org","sentAt":"2011-12-29T01:27:59Z","receivedAt":"2011-12-29T01:27:59Z","isPatch":false,"sender":{"key":"michael.horowitz@ieee.org","avatar":null},"body":"Hello all,\n\nI have been unable to find a solution to this, so I figured I would\npost to this list...\n\nI am trying to make an easy command to let me look at the last diff to\na specified file, either plain or with a diff tool, such as vimdiff.\nThis is the last actual change, not just HEAD^, because the file may\nnot have changed in many commits.\n\nI was able to make the following 2 aliases, which work perfectly\nexcept for one problem...\n\nldiff = \"!git diff `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\nldifft = \"!git difftool `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\n\nThe problem is the limitation that shell commands are always executed\nat the top-level directory of the repository.  Normally I am in a\ndeeply nested directory, so if I specify the file name in that\ndirectory, it doesn't work.  Having to specify the full path relative\nto the top level makes these aliases more cumbersome to use than their\nworth.\n\nIs there a way to get around this, or even a completely different way\nto do this that I am missing?  I want to avoid making a completely\nseparate shell script.\n\nThanks,\n\nMike\n"},{"id":"181772","messageId":"87wr9g2hcd.fsf@catnip.gol.com","threadId":"29261","inReplyTo":"CAFLRbopjqW7OEWN4kxy+6Gb828h4zBC_h=4WiP-q1__LeezxUw@mail.gmail.com","subject":"Re: git alias question","fromName":"Miles Bader","fromEmail":"miles@gnu.org","sentAt":"2011-12-29T03:21:22Z","receivedAt":"2011-12-29T03:21:22Z","isPatch":false,"sender":{"key":"miles@gnu.org","avatar":"https://gravatar.com/avatar/01069b69593af7bff28e2f97afeb3644ae6fe2f5f56cb3a8cf34c5fb8c36efe5?d=mp&s=160"},"body":"Michael Horowitz <michael.horowitz@ieee.org> writes:\n> I was able to make the following 2 aliases, which work perfectly\n> except for one problem...\n>\n> ldiff = \"!git diff `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\n> ldifft = \"!git difftool `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\n>\n> The problem is the limitation that shell commands are always executed\n> at the top-level directory of the repository.\n\nHmmm, it'd be cool if git exported an environment variable containing\nthe CWD when it invoked external aliases like this...!\n\n-Miles\n\n-- \nLove is the difficult realization that something other than oneself is real.\n[Iris Murdoch]\n"},{"id":"181774","messageId":"7vy5twx7rh.fsf@alter.siamese.dyndns.org","threadId":"29261","inReplyTo":"87wr9g2hcd.fsf@catnip.gol.com","subject":"Re: git alias question","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-29T05:32:34Z","receivedAt":"2011-12-29T05:32:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miles Bader <miles@gnu.org> writes:\n\n> Michael Horowitz <michael.horowitz@ieee.org> writes:\n>> I was able to make the following 2 aliases, which work perfectly\n>> except for one problem...\n>>\n>> ldiff = \"!git diff `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\n>> ldifft = \"!git difftool `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\n>>\n>> The problem is the limitation that shell commands are always executed\n>> at the top-level directory of the repository.\n>\n> Hmmm, it'd be cool if git exported an environment variable containing\n> the CWD when it invoked external aliases like this...!\n\nYeah, something like GIT_PREFIX environment variable, I guess.\n"},{"id":"181781","messageId":"CAD0k6qTp9sKCb==Jh1vuLuZoxx99Kt2Z=VAbjYbGaUE7nbOxdQ@mail.gmail.com","threadId":"29261","inReplyTo":"CAFLRbopjqW7OEWN4kxy+6Gb828h4zBC_h=4WiP-q1__LeezxUw@mail.gmail.com","subject":"Re: git alias question","fromName":"Dave Borowitz","fromEmail":"dborowitz@google.com","sentAt":"2011-12-29T17:08:16Z","receivedAt":"2011-12-29T17:08:16Z","isPatch":false,"sender":{"key":"dborowitz@google.com","avatar":"https://avatars.githubusercontent.com/u/194927?v=4"},"body":"On Wed, Dec 28, 2011 at 17:27, Michael Horowitz\n<michael.horowitz@ieee.org> wrote:\n> ldiff = \"!git diff `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\n\nFWIW, you can also do this as:\n  ldiff = log -p -1 --format=format: --\n\n> ldifft = \"!git difftool `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\n\nI don't know that you can do something equivalent with difftool. I\nsuppose you could do the above with \"GIT_EXTERNAL_DIFF=<some difftool\nwrapper> git ldiff\", but that's not very helpful.\n"},{"id":"181792","messageId":"CAJDDKr5a8TB82h4ULWtamLOVu_4Fv+cGw1YfEL987gM3yM4TMg@mail.gmail.com","threadId":"29261","inReplyTo":"CAD0k6qTp9sKCb==Jh1vuLuZoxx99Kt2Z=VAbjYbGaUE7nbOxdQ@mail.gmail.com","subject":"Re: git alias question","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2011-12-30T01:59:58Z","receivedAt":"2011-12-30T01:59:58Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Thu, Dec 29, 2011 at 9:08 AM, Dave Borowitz <dborowitz@google.com> wrote:\n> On Wed, Dec 28, 2011 at 17:27, Michael Horowitz\n> <michael.horowitz@ieee.org> wrote:\n>> ldiff = \"!git diff `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\n>\n> FWIW, you can also do this as:\n>  ldiff = log -p -1 --format=format: --\n>\n>> ldifft = \"!git difftool `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\n>\n> I don't know that you can do something equivalent with difftool. I\n> suppose you could do the above with \"GIT_EXTERNAL_DIFF=<some difftool\n> wrapper> git ldiff\", but that's not very helpful.\n\ndifftool cannot be driven by log right now.  It is something we\nthought would be helpful in the past:\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/114269/focus=114367\n\nOn 2009-03-23 Junio C Hamano <gitster <at> pobox.com> wrote:\n> Perhaps we would want a convenient way for \"log -p\" or \"show -p\" to drive\n> difftool as a backend?\n\nI think that's exactly it.  difftool wraps diff; a log equivalent\nwould be quite helpful.\n\nOne idea is for difftool to learn a \"--log\" option to make it wrap log\ninstead.  I don't know if a diff-like command having a \"--log\" option\nis ideal from a consistency-of-user-interface POV so I'm open to\nideas.  It is convenient, though.  It does seem like difftool would be\na good place to expose this feature.\n\nI'd be interested in the \"teach log / show -p about GIT_EXTERNAL_DIFF\"\nroute, if that sounds like a good idea.\n-- \n            David\n"},{"id":"181818","messageId":"CAFLRborAuoWKxOeHtPRujSYbQPk67RCxTiVBavtWDeh-Byfa2w@mail.gmail.com","threadId":"29261","inReplyTo":"CAJDDKr5a8TB82h4ULWtamLOVu_4Fv+cGw1YfEL987gM3yM4TMg@mail.gmail.com","subject":"Re: git alias question","fromName":"Michael Horowitz","fromEmail":"michael.horowitz@ieee.org","sentAt":"2011-12-31T21:31:18Z","receivedAt":"2011-12-31T21:31:18Z","isPatch":false,"sender":{"key":"michael.horowitz@ieee.org","avatar":null},"body":"The log operation does seem to make the most sense as the mechanism to\nsearch for the results.  Making it work with difftool would work...\nNot sure if \"--log\" to difftool or some other options as suggested in\nthe other thread would be most consistent UI-wise as stated, but\neither would work for me.\n\nOn a separate note, some environment variable like GIT_PREFIX with the\nCWD would make the alias functionality more flexible.\n\nMike\n\nOn Thu, Dec 29, 2011 at 8:59 PM, David Aguilar <davvid@gmail.com> wrote:\n>\n> On Thu, Dec 29, 2011 at 9:08 AM, Dave Borowitz <dborowitz@google.com> wrote:\n> > On Wed, Dec 28, 2011 at 17:27, Michael Horowitz\n> > <michael.horowitz@ieee.org> wrote:\n> >> ldiff = \"!git diff `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\n> >\n> > FWIW, you can also do this as:\n> >  ldiff = log -p -1 --format=format: --\n> >\n> >> ldifft = \"!git difftool `git rev-list --reverse -n 2 HEAD -- $1` -- $1\"\n> >\n> > I don't know that you can do something equivalent with difftool. I\n> > suppose you could do the above with \"GIT_EXTERNAL_DIFF=<some difftool\n> > wrapper> git ldiff\", but that's not very helpful.\n>\n> difftool cannot be driven by log right now.  It is something we\n> thought would be helpful in the past:\n>\n> http://thread.gmane.org/gmane.comp.version-control.git/114269/focus=114367\n>\n> On 2009-03-23 Junio C Hamano <gitster <at> pobox.com> wrote:\n> > Perhaps we would want a convenient way for \"log -p\" or \"show -p\" to drive\n> > difftool as a backend?\n>\n> I think that's exactly it.  difftool wraps diff; a log equivalent\n> would be quite helpful.\n>\n> One idea is for difftool to learn a \"--log\" option to make it wrap log\n> instead.  I don't know if a diff-like command having a \"--log\" option\n> is ideal from a consistency-of-user-interface POV so I'm open to\n> ideas.  It is convenient, though.  It does seem like difftool would be\n> a good place to expose this feature.\n>\n> I'd be interested in the \"teach log / show -p about GIT_EXTERNAL_DIFF\"\n> route, if that sounds like a good idea.\n> --\n>             David\n"},{"id":"181819","messageId":"m3zke8e2vh.fsf@localhost.localdomain","threadId":"29261","inReplyTo":"CAFLRborAuoWKxOeHtPRujSYbQPk67RCxTiVBavtWDeh-Byfa2w@mail.gmail.com","subject":"Re: git alias question","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-12-31T23:30:00Z","receivedAt":"2011-12-31T23:30:00Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Michael Horowitz <michael.horowitz@ieee.org> writes:\n\n> The log operation does seem to make the most sense as the mechanism to\n> search for the results.  Making it work with difftool would work...\n> Not sure if \"--log\" to difftool or some other options as suggested in\n> the other thread would be most consistent UI-wise as stated, but\n> either would work for me.\n> \n> On a separate note, some environment variable like GIT_PREFIX with the\n> CWD would make the alias functionality more flexible.\n\n1f5d271 (setup: Provide GIT_PREFIX to built-ins, 2011-05-25) is\npresent in v1.7.7; 7cf16a1 (handle_alias: provide GIT_PREFIX to\n!alias, 2011-04-27) is in 1.7.6\n\n-- \nJakub Narebski\n"},{"id":"181834","messageId":"CAFLRbopp1ROfMqp3PVdUQ37_fdku2FtV-=pxuYk-YA-+_wgjPg@mail.gmail.com","threadId":"29261","inReplyTo":"m3zke8e2vh.fsf@localhost.localdomain","subject":"Re: git alias question","fromName":"Michael Horowitz","fromEmail":"michael.horowitz@ieee.org","sentAt":"2012-01-02T05:57:44Z","receivedAt":"2012-01-02T05:57:44Z","isPatch":false,"sender":{"key":"michael.horowitz@ieee.org","avatar":null},"body":"Nice, works perfectly!  Didn't notice that was there, guess last time\nI looked, I was using an older version.  I see it is in the git config\nman page and all now.\n\nThanks,\n\nMike\n\n\n\nOn Sat, Dec 31, 2011 at 6:30 PM, Jakub Narebski <jnareb@gmail.com> wrote:\n>\n> Michael Horowitz <michael.horowitz@ieee.org> writes:\n>\n> > The log operation does seem to make the most sense as the mechanism to\n> > search for the results.  Making it work with difftool would work...\n> > Not sure if \"--log\" to difftool or some other options as suggested in\n> > the other thread would be most consistent UI-wise as stated, but\n> > either would work for me.\n> >\n> > On a separate note, some environment variable like GIT_PREFIX with the\n> > CWD would make the alias functionality more flexible.\n>\n> 1f5d271 (setup: Provide GIT_PREFIX to built-ins, 2011-05-25) is\n> present in v1.7.7; 7cf16a1 (handle_alias: provide GIT_PREFIX to\n> !alias, 2011-04-27) is in 1.7.6\n>\n> --\n> Jakub Narebski\n"}]}