git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: A new way to get a sha1?

From
Jeff King <peff@peff.net>
Date
Jul 30, 2012, 16:51 UTC
Message-ID
<20120730165147.GD16701@sigill.intra.peff.net>
In-Reply-To
<CAFjFENqGTumBRkDX4vJjQhGz0CrEC1VU1cDHWCERywa8vjVbRw@mail.gmail.com>
On Mon, Jul 30, 2012 at 06:40:12PM +0200, Thomas Badie wrote:
Show 10 quoted lines
> 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.

-Peff
Previous: Thomas BadieNext: Thomas Badie
Message 10 of 16 in “A new way to get a sha1?”
  1. Thomas BadieJul 30, 2012
  2. Jan EngelhardtJul 30, 2012
  3. Junio C HamanoJul 30, 2012
  4. Thomas BadieJul 30, 2012
  5. Martin LanghoffJul 30, 2012
  6. Junio C HamanoJul 30, 2012
  7. Martin LanghoffJul 30, 2012
  8. Andreas SchwabJul 30, 2012
  9. Thomas BadieJul 30, 2012
  10. Jeff KingJul 30, 2012
  11. Thomas BadieJul 30, 2012
  12. Andreas SchwabJul 30, 2012
  13. Sitaram ChamartyJul 30, 2012
  14. Thomas BadieJul 30, 2012
  15. Thomas RastJul 30, 2012
  16. Thomas BadieJul 30, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.