Thread (7 messages) flat view 7 messages, 4 authors, 2016-06-15

Re: A new way to get a sha1?

From: Thomas Badie <hidden>
Date: 2016-06-15 22:54:23

2012/7/30 Jeff King [off-list ref]:
On Mon, Jul 30, 2012 at 06:40:12PM +0200, Thomas Badie wrote:
quoted
I understand your opinion. My solution was a easier way to make your
proposition about `git log --oneline`, because I don't want to copy these
6 numbers by hand. I'd prefer select the right line simply.

My solution is intended for people who just use git, and whatever their
environment (Unix, Windows...) because all is contained in git.

But I clearly agree that there is a lot of other solutions by using external
tools.  But IMHO, it is preferable that I just have to add a `-i' to a command
to make this choice simply, and not having to use my WM for this kind of task.
I am pretty mouse-averse, and I find a nice solution to these sorts of
interactive-selection problems is to use your editor. In its most basic
form, something like:

  git log --oneline >tmp
  $EDITOR tmp ;# and delete everything you don't want
  git cherry-pick `cat tmp`

assuming you are proficient with your editor, finding the entry you want
and deleting all of the unwanted lines should be just a few keystrokes.
And you can simplify it with a script like this:

  $ cat `which vpipe`
  #!/bin/sh
  trap 'rm -f $tmp' 0
  tmp=`mktemp vpipe-XXXXXX` &&
  cat >$tmp &&
  ${EDITOR:-vi} $tmp </dev/tty >/dev/tty &&
  cat $tmp

which you can then use like:

  git cherry-pick `git log | vpipe`

I know that sort of thing is not for everyone (you have to really like
your editor), but I thought I'd share in case it is useful.
For this case, I don't think I'll use it, but it shows how to use the editor
in a replacement of an interactive tool, and it is interesting. I'd change
vi for emacs but this is religious. I never though using my editor this way,
and maybe one day it will be useful.

Thanks for your answer.

-- 
Thomas Badie
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help