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

Re: A new way to get a sha1?

From
Thomas Badie <thomas.badie@gmail.com>
Date
Jul 30, 2012, 17:33 UTC
Message-ID
<CAFjFENrBskVHYZT1rLnAYXDjUJ_2HrFR7+L1=HrEV5iOWXZt8g@mail.gmail.com>
In-Reply-To
<20120730165147.GD16701@sigill.intra.peff.net>
2012/7/30 Jeff King <peff@peff.net>:
Show 39 quoted lines
> On Mon, Jul 30, 2012 at 06:40:12PM +0200, Thomas Badie wrote:
>
>> 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
Previous: Jeff KingNext: Andreas Schwab
Message 11 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.