{"thread":{"id":"31136","subject":"A new way to get a sha1?","startedAt":"2012-07-30T12:11:30Z","lastAt":"2012-07-30T18:42:33Z","messageCount":16,"participants":["Thomas Badie","Jan Engelhardt","Sitaram Chamarty","Junio C Hamano","Thomas Rast","Jeff King","Andreas Schwab","Martin Langhoff"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"196116","messageId":"jv5tln$96e$1@dough.gmane.org","threadId":"31136","inReplyTo":null,"subject":"A new way to get a sha1?","fromName":"Thomas Badie","fromEmail":"thomas.badie@gmail.com","sentAt":"2012-07-30T12:11:30Z","receivedAt":"2012-07-30T12:11:30Z","isPatch":false,"sender":{"key":"thomas.badie@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1281881?v=4"},"body":"Hi all,\n\nWhen I should fixup or squash a commit, I nearly never\nremember how to get the sha1 of the commit I want to fixup.\nBecause sometimes HEAD~n is not enough, I make `git log`,\ncopy the sha1 of the right commit and paste it in my git\nfixup command. So I wrote a perl script to avoid the usage\nof the mouse. And after discussion with some of my friends,\nthis can be generalized as a generic command line interface\ntool to get a sha1.\n\nThe idea is to have a perl module which run through\nthe log history and print 10 shortlog associated with a number\nfrom 0 to 9, and a message below \"Select commit [| 0, 9 |] or\nnext row ?\" or this kind of message with several options.\n\nSo I ask to the community if this module is interesting for git.\nIt can be integrated everywhere a sha1 is requested (git rebase,\ngit reset, ...). IMHO, it can be an enhancement.\n\nSo, what is your opinion? Should I make this script a perl module\nand integrate it in git, or should I just keep it in my own script\ntoolbox?\n\nThanks for reading and answering,\n\n-- \nThomas \"Enki\" Badie \n"},{"id":"196119","messageId":"alpine.LNX.2.01.1207301426090.25013@frira.zrqbmnf.qr","threadId":"31136","inReplyTo":"jv5tln$96e$1@dough.gmane.org","subject":"Re: A new way to get a sha1?","fromName":"Jan Engelhardt","fromEmail":"jengelh@inai.de","sentAt":"2012-07-30T12:28:36Z","receivedAt":"2012-07-30T12:28:36Z","isPatch":false,"sender":{"key":"jengelh@inai.de","avatar":"https://avatars.githubusercontent.com/u/8861948?v=4"},"body":"On Monday 2012-07-30 14:11, Thomas Badie wrote:\n\n>Hi all,\n>\n>When I should fixup or squash a commit, I nearly never\n>remember how to get the sha1 of the commit I want to fixup.\n>Because sometimes HEAD~n is not enough, I make `git log`,\n>copy the sha1 of the right commit and paste it in my git\n>fixup command. So I wrote a perl script to avoid the usage\n>of the mouse.\n\nIf you use screen(1), you can use the keyboard as well; it offers ^A [ \nand ^A ] for copy, and then paste. tmux and all those screen clones \nprobably have something similar. Maybe ratpoison-like WMs do as well.\nOr, you can use `git log --oneline`, look for the commit and then\ntype the (usually) 6-char part of the hash manually, which may be faster \nthan ^A[, moving the cursor to the copy position, marking it, etc.\n\n>So, what is your opinion?\n\nIMO, I thus never needed an extra tool to find and specify the hash for \n`git re -i hash^`..\n\nmy ¥2\n"},{"id":"196121","messageId":"CAMK1S_hhYi=dLrPy2j28=QMi-UDg7ZGXU=t9WqykVmx3XRyswQ@mail.gmail.com","threadId":"31136","inReplyTo":"jv5tln$96e$1@dough.gmane.org","subject":"Re: A new way to get a sha1?","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2012-07-30T12:41:40Z","receivedAt":"2012-07-30T12:41:40Z","isPatch":false,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"On Mon, Jul 30, 2012 at 5:41 PM, Thomas Badie <thomas.badie@gmail.com> wrote:\n> Hi all,\n>\n> When I should fixup or squash a commit, I nearly never\n> remember how to get the sha1 of the commit I want to fixup.\n> Because sometimes HEAD~n is not enough, I make `git log`,\n> copy the sha1 of the right commit and paste it in my git\n> fixup command. So I wrote a perl script to avoid the usage\n> of the mouse. And after discussion with some of my friends,\n> this can be generalized as a generic command line interface\n> tool to get a sha1.\n>\n> The idea is to have a perl module which run through\n> the log history and print 10 shortlog associated with a number\n> from 0 to 9, and a message below \"Select commit [| 0, 9 |] or\n> next row ?\" or this kind of message with several options.\n\nIn general, I prefer nothing to be *interactive*, so I would vote an\nemphatic no.\n\nAlso, try \"tig\" and see if you can customise it.  For example, in\norder to create a new commit that is meant to be a fixup of some other\ncommit, I 'git add' what is needed (either command line or tig again)\nthen hit \"m\" to the main window, scroll down to the commit concerned,\nand hit \"=\".\n\nThat \"=\" comes from this line in ~/.tigrc:\n\n    bind    main            =   !git commit --fixup=%(commit)\n\nPlease use such methods to keep interactivity where it belongs, is my opinion.\n"},{"id":"196147","messageId":"7vipd5s161.fsf@alter.siamese.dyndns.org","threadId":"31136","inReplyTo":"alpine.LNX.2.01.1207301426090.25013@frira.zrqbmnf.qr","subject":"Re: A new way to get a sha1?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-30T15:45:26Z","receivedAt":"2012-07-30T15:45:26Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jan Engelhardt <jengelh@inai.de> writes:\n\n> On Monday 2012-07-30 14:11, Thomas Badie wrote:\n>\n>>Hi all,\n>>\n>>When I should fixup or squash a commit, I nearly never\n>>remember how to get the sha1 of the commit I want to fixup.\n>>Because sometimes HEAD~n is not enough, I make `git log`,\n>>copy the sha1 of the right commit and paste it in my git\n>>fixup command. So I wrote a perl script to avoid the usage\n>>of the mouse.\n>\n> If you use screen(1), you can use the keyboard as well; it offers ^A [ \n> and ^A ] for copy, and then paste. tmux and all those screen clones \n> probably have something similar. Maybe ratpoison-like WMs do as well.\n> Or, you can use `git log --oneline`, look for the commit and then\n> type the (usually) 6-char part of the hash manually, which may be faster \n> than ^A[, moving the cursor to the copy position, marking it, etc.\n\nAlso,\n\n\tgit show -s ':/^t1100-.*: Fix an interm'\n\nwould work well.  It your log messages are not descriptive enough,\nhowever, that may not, but that is easily fixable by training you\nand your colleages to give a more descriptive title to each commit,\nwhich will make your project better.\n"},{"id":"196149","messageId":"87k3xli6mn.fsf@thomas.inf.ethz.ch","threadId":"31136","inReplyTo":"jv5tln$96e$1@dough.gmane.org","subject":"Re: A new way to get a sha1?","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2012-07-30T15:57:36Z","receivedAt":"2012-07-30T15:57:36Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Thomas Badie <thomas.badie@gmail.com> writes:\n\n> The idea is to have a perl module which run through\n> the log history and print 10 shortlog associated with a number\n> from 0 to 9, and a message below \"Select commit [| 0, 9 |] or\n> next row ?\" or this kind of message with several options.\n>\n> So I ask to the community if this module is interesting for git.\n> It can be integrated everywhere a sha1 is requested (git rebase,\n> git reset, ...). IMHO, it can be an enhancement.\n\nI think this is too specific.  If you want full interactivity, use a\nreal interactive tool like tig.\n\nHowever, your post and some quick searching gave me another idea.  Bash\nactually has features to let you edit the current command line from\nwithin key bindings.  So if only we had some clever utility, let's call\nit lineselect for lack of a better name, that let us do\n\n  git log --oneline <args> | lineselect\n\nthen we could paste the selected SHA1 into the command line.  That would\nbe really neat, wouldn't it?\n\nI haven't found such a utility, so below is my first shot at making\nsomething useful.  It has:\n\n* a few keybinds that should make most people happy\n* color rendering (yay), but because of issues with the default\n  rendering, it sets white-on-black by default\n* an optional regex arg to select only parts of the lines\n\nThings that notably _don't_ work yet:\n\n* cursor keys (I have no idea why it doesn't match KEY_UP etc.)\n* ANSI attributes (colors work, of sorts)\n* Searching the next occurrence of a search string\n\nBut you can probably guess that those aren't a huge problem for me.\n\nI made a little repo too, for all your forking needs:\n\n  https://github.com/trast/lineselect.git\n  git://github.com/trast/lineselect.git\n\nThanks for the idea :-)\n\n\n------ 8< ------\n#!/usr/bin/perl\n\nuse warnings;\nuse strict;\nuse Curses;\n\nmy @lines;\n\nopen my $input, \"<&STDIN\" or die \"Can't dup STDIN: $!\";\nopen my $output, \">&STDOUT\" or die \"Can't dup STDOUT: $!\";\nopen STDIN, \"<\", \"/dev/tty\" or die \"Can't open TTY (in): $!\";\nopen STDOUT, \">\", \"/dev/tty\" or die \"Can't open TTY (out): $!\";\n\nmy $eof = -1;\n\nsub read_more {\n\tmy $n = $_[0];\n\tif ($eof > 0) {\n\t\treturn;\n\t}\n\twhile ($n >= scalar @lines) {\n\t\tmy $read = <$input>;\n\t\tif (!defined $read) {\n\t\t\t$eof = scalar @lines;\n\t\t\treturn;\n\t\t}\n\t\tpush @lines, $read;\n\t}\n}\n\nmy $pat;\nmy ($rows, $cols);\nmy $sel = 0;\n\nmy $top = 0;\n\nmy $cmdline = \":\";\n\nmy $fg = 7;\nmy $bg = 0;\nsub set_color {\n\tattron(COLOR_PAIR(1+$fg+8*$bg));\n}\n\nsub print_color_line {\n\tmy $line = $_[0];\n\tmy $remain = $cols;\n\t$fg = 7;\n\t$bg = 0;\n\tset_color;\n\twhile ($line =~ m{^([^\\e]*)\\e\\[([^m]*)m(.*)}) {\n\t\tprintw($1);\n\t\t$remain -= length $1;\n\t\t$line = $3;\n\t\tif ($2 eq \"\") {\n\t\t\t$fg = 7;\n\t\t\t$bg = 0;\n\t\t\tset_color;\n\t\t} else {\n\t\t\tfor my $c (split /;/, $2) {\n\t\t\t\tif (30 <= $c and $c < 38) {\n\t\t\t\t\t$fg = $c - 30;\n\t\t\t\t} elsif (40 <= $c and $c < 48) {\n\t\t\t\t\t$bg = $c - 30;\n\t\t\t\t}\n\t\t\t}\n\t\t\tset_color;\n\t\t}\n\t}\n\tprintw($line);\n\t$remain -= length $line;\n\tif ($remain > 0) {\n\t\tprintw(\" \"x$remain);\n\t}\n}\n\nsub redraw {\n\tread_more $top+$rows-1;\n\tclear;\n\tattron(COLOR_PAIR(8));\n\tfor my $i (0..$rows-2) {\n\t\tif ($top+$i == $sel) {\n\t\t\tattron(A_STANDOUT);\n\t\t} else {\n\t\t\tattroff(A_STANDOUT);\n\t\t}\n\t\tmove($i, 0);\n\t\tprint_color_line($lines[$top+$i]);\n\t}\n\tmove($rows-1, 0);\n\tattron(COLOR_PAIR(8));\n\tattron(A_STANDOUT);\n\tprintw($cmdline);\n\tattroff(A_STANDOUT);\n\trefresh();\n}\n\nsub adjust_view {\n\tif ($sel < 0) {\n\t\treturn;\n\t} elsif ($sel >= $top+$rows-1) {\n\t\t$top = $sel-$rows+2;\n\t} elsif ($sel < $top) {\n\t\t$top = $sel;\n\t}\n}\n\nsub forward;\nsub backward {\n\tmy $n = $_[0];\n\t$sel -= $n;\n\twhile (defined $pat and $lines[$sel] !~ m{$pat}) {\n\t\t$sel--;\n\t\tread_more $sel;\n\t\tif ($sel < 0) {\n\t\t\t$sel = 0;\n\t\t\tforward 0;\n\t\t\treturn;\n\t\t}\n\t}\n\tif ($sel < 0) {\n\t\t$sel = 0;\n\t}\n\tadjust_view;\n}\n\nsub forward {\n\tmy $n = $_[0];\n\t$sel += $n;\n\twhile (defined $pat and $lines[$sel] !~ m{$pat}) {\n\t\t$sel++;\n\t\tread_more $sel;\n\t\tif ($eof > 0 and $sel >= $eof) {\n\t\t\t$sel = $eof-1;\n\t\t\tbackward 0;\n\t\t\treturn;\n\t\t}\n\t}\n\tadjust_view;\n}\n\nsub search {\n\tmy $start = $sel;\n\tmy $search_str = \"\";\n\twhile (1) {\n\t\t$sel = $start;\n\t\tmy $case_sens = ($search_str ne lc $search_str);\n\t\twhile (1) {\n\t\t\tif ($eof > 0 and $sel >= $eof) {\n\t\t\t\t$sel = -1;\n\t\t\t\tlast;\n\t\t\t}\n\t\t\tif (defined $pat and $lines[$sel] !~ m{$pat}) {\n\t\t\t\t$sel++;\n\t\t\t\tread_more $sel;\n\t\t\t\tnext;\n\t\t\t}\n\t\t\tif ($case_sens and $lines[$sel] =~ m{$search_str}) {\n\t\t\t\tlast;\n\t\t\t}\n\t\t\tif (!$case_sens and $lines[$sel] =~ m{$search_str}i) {\n\t\t\t\tlast;\n\t\t\t}\n\t\t\t$sel++;\n\t\t\tread_more $sel;\n\t\t}\n\t\tadjust_view;\n\t\t$cmdline = \"/\" . $search_str;\n\t\t$cmdline = \"NO MATCH -- \" . $cmdline if $sel < 0;\n\t\tredraw;\n\t\tmy $c = getch();\n\t\tif ($c eq \"\\b\" or $c eq \"\\x7f\") {\n\t\t\t$search_str = substr $search_str, 0, length($search_str)-1;\n\t\t} elsif ($c eq \"\\n\") {\n\t\t\t$sel = $start if $sel < 0;\n\t\t\treturn;\n\t\t} elsif ($c eq \"\\033\") {\n\t\t\t$sel = $start;\n\t\t\treturn;\n\t\t} else {\n\t\t\t$search_str .= $c;\n\t\t}\n\t}\n}\n\nsub mainloop {\n\twhile (1) {\n\t\tgetmaxyx($rows, $cols);\n\t\t$cmdline = \":\";\n\t\tredraw;\n\t\tmy $c = getch();\n\t\tif ($c eq \" \") {\n\t\t\t$sel += $rows-1;\n\t\t\tread_more $sel;\n\t\t\t$sel = $eof-1 if $eof > 0 and $sel > $eof;\n\t\t\tadjust_view;\n\t\t} elsif ($c eq \"q\") {\n\t\t\treturn;\n\t\t} elsif ($c eq KEY_ENTER or $c eq \"\\n\") {\n\t\t\treturn $lines[$sel];\n\t\t} elsif ($c eq \"n\" or $c eq \"j\" or $c eq KEY_DOWN) {\n\t\t\tforward 1;\n\t\t} elsif ($c eq \"p\" or $c eq \"k\" or $c eq KEY_UP) {\n\t\t\tbackward 1;\n\t\t} elsif ($c eq \"/\" or $c eq \"f\") {\n\t\t\tsearch;\n\t\t} elsif ($c eq \"<\" or $c eq KEY_HOME) {\n\t\t\t$sel = 0;\n\t\t\tadjust_view;\n\t\t} elsif ($c eq \">\" or $c eq KEY_END) {\n\t\t\twhile ($eof < 0) {\n\t\t\t\t$sel++;\n\t\t\t\tread_more $sel;\n\t\t\t}\n\t\t\t$sel = $eof-1;\n\t\t\tadjust_view;\n\t\t}\n\t}\n}\n\nif (0 < scalar @ARGV) {\n\t$pat = $ARGV[0];\n}\n\ninitscr;\nstart_color;\nfor my $f (0..7) {\n\tfor my $b (0..7) {\n\t\tinit_pair(1+$f+8*$b,$f,$b);\n\t}\n}\nmy $r = mainloop;\nendwin;\nif (defined $r) {\n\t$r =~ s{\\e\\[([^m]*)m}{}g;\n\tif (defined $pat) {\n\t\t$r =~ m/$pat/;\n\t\t$r = $1;\n\t\tdie \"BUG: should never get here\" if (!defined $r);\n\t}\n\tprint $output \"$r\";\n} else {\n\texit 1;\n}\n"},{"id":"196157","messageId":"CAFjFENqGTumBRkDX4vJjQhGz0CrEC1VU1cDHWCERywa8vjVbRw@mail.gmail.com","threadId":"31136","inReplyTo":"alpine.LNX.2.01.1207301426090.25013@frira.zrqbmnf.qr","subject":"Re: A new way to get a sha1?","fromName":"Thomas Badie","fromEmail":"thomas.badie@gmail.com","sentAt":"2012-07-30T16:40:12Z","receivedAt":"2012-07-30T16:40:12Z","isPatch":false,"sender":{"key":"thomas.badie@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1281881?v=4"},"body":"2012/7/30 Jan Engelhardt <jengelh@inai.de>:\n> On Monday 2012-07-30 14:11, Thomas Badie wrote:\n>\n>>Hi all,\n>>\n>>When I should fixup or squash a commit, I nearly never\n>>remember how to get the sha1 of the commit I want to fixup.\n>>Because sometimes HEAD~n is not enough, I make `git log`,\n>>copy the sha1 of the right commit and paste it in my git\n>>fixup command. So I wrote a perl script to avoid the usage\n>>of the mouse.\n>\n> If you use screen(1), you can use the keyboard as well; it offers ^A [\n> and ^A ] for copy, and then paste. tmux and all those screen clones\n> probably have something similar. Maybe ratpoison-like WMs do as well.\n> Or, you can use `git log --oneline`, look for the commit and then\n> type the (usually) 6-char part of the hash manually, which may be faster\n> than ^A[, moving the cursor to the copy position, marking it, etc.\n>\n>>So, what is your opinion?\n>\n> IMO, I thus never needed an extra tool to find and specify the hash for\n> `git re -i hash^`..\n>\n> my ¥2\n\nI understand your opinion. My solution was a easier way to make your\nproposition about `git log --oneline`, because I don't want to copy these\n6 numbers by hand. I'd prefer select the right line simply.\n\nMy solution is intended for people who just use git, and whatever their\nenvironment (Unix, Windows...) because all is contained in git.\n\nBut I clearly agree that there is a lot of other solutions by using external\ntools.  But IMHO, it is preferable that I just have to add a `-i' to a command\nto make this choice simply, and not having to use my WM for this kind of task.\n\nMy real proposal is to integrate this way of choice into git instead of having\nto use external tools, or writting the part of the sha1 by hand.\n\nThanks for answering, your answer confirms that this kind of tools is really\nnot wanted by everyone.\n\nI will take a look at screen, it can be useful for a lot of thing. Thanks for\nyour advice.\n\n-- \nThomas \"Enki\" Badie\n"},{"id":"196158","messageId":"CAFjFENpqC9MVw4Fx_6rgBsLx8p-5_XGh20Wd4SG17OeyDZg6ag@mail.gmail.com","threadId":"31136","inReplyTo":"CAMK1S_hhYi=dLrPy2j28=QMi-UDg7ZGXU=t9WqykVmx3XRyswQ@mail.gmail.com","subject":"Re: A new way to get a sha1?","fromName":"Thomas Badie","fromEmail":"thomas.badie@gmail.com","sentAt":"2012-07-30T16:49:21Z","receivedAt":"2012-07-30T16:49:21Z","isPatch":false,"sender":{"key":"thomas.badie@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1281881?v=4"},"body":"2012/7/30 Sitaram Chamarty <sitaramc@gmail.com>:\n> On Mon, Jul 30, 2012 at 5:41 PM, Thomas Badie <thomas.badie@gmail.com> wrote:\n>> Hi all,\n>>\n>> When I should fixup or squash a commit, I nearly never\n>> remember how to get the sha1 of the commit I want to fixup.\n>> Because sometimes HEAD~n is not enough, I make `git log`,\n>> copy the sha1 of the right commit and paste it in my git\n>> fixup command. So I wrote a perl script to avoid the usage\n>> of the mouse. And after discussion with some of my friends,\n>> this can be generalized as a generic command line interface\n>> tool to get a sha1.\n>>\n>> The idea is to have a perl module which run through\n>> the log history and print 10 shortlog associated with a number\n>> from 0 to 9, and a message below \"Select commit [| 0, 9 |] or\n>> next row ?\" or this kind of message with several options.\n>\n> In general, I prefer nothing to be *interactive*, so I would vote an\n> emphatic no.\n\nI can understand this. But maybe this is not the case of everyone. People\non this mailing-list are developers for several years I think, and this kind of\ntools may not be helpful for them because they have their own habits. When\nI decide to propose this, I mostly think about people who are not allergic to\ninteractive tools (this allergy is highly understandable, I just say\nthere is a lot\nof taste in the world). So maybe it could be an enhancement for git, maybe not.\n\n> Also, try \"tig\" and see if you can customise it.  For example, in\n> order to create a new commit that is meant to be a fixup of some other\n> commit, I 'git add' what is needed (either command line or tig again)\n> then hit \"m\" to the main window, scroll down to the commit concerned,\n> and hit \"=\".\n>\n> That \"=\" comes from this line in ~/.tigrc:\n>\n>     bind    main            =   !git commit --fixup=%(commit)\n>\n> Please use such methods to keep interactivity where it belongs, is my opinion.\n\nI already heard about \"tig\" without trying it. I'll try it as soon as possible.\nThanks for your answer.\n\n-- \nThomas \"Enki\" Badie\n"},{"id":"196159","messageId":"20120730165147.GD16701@sigill.intra.peff.net","threadId":"31136","inReplyTo":"CAFjFENqGTumBRkDX4vJjQhGz0CrEC1VU1cDHWCERywa8vjVbRw@mail.gmail.com","subject":"Re: A new way to get a sha1?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-07-30T16:51:47Z","receivedAt":"2012-07-30T16:51:47Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jul 30, 2012 at 06:40:12PM +0200, Thomas Badie wrote:\n\n> I understand your opinion. My solution was a easier way to make your\n> proposition about `git log --oneline`, because I don't want to copy these\n> 6 numbers by hand. I'd prefer select the right line simply.\n> \n> My solution is intended for people who just use git, and whatever their\n> environment (Unix, Windows...) because all is contained in git.\n> \n> But I clearly agree that there is a lot of other solutions by using external\n> tools.  But IMHO, it is preferable that I just have to add a `-i' to a command\n> to make this choice simply, and not having to use my WM for this kind of task.\n\nI am pretty mouse-averse, and I find a nice solution to these sorts of\ninteractive-selection problems is to use your editor. In its most basic\nform, something like:\n\n  git log --oneline >tmp\n  $EDITOR tmp ;# and delete everything you don't want\n  git cherry-pick `cat tmp`\n\nassuming you are proficient with your editor, finding the entry you want\nand deleting all of the unwanted lines should be just a few keystrokes.\nAnd you can simplify it with a script like this:\n\n  $ cat `which vpipe`\n  #!/bin/sh\n  trap 'rm -f $tmp' 0\n  tmp=`mktemp vpipe-XXXXXX` &&\n  cat >$tmp &&\n  ${EDITOR:-vi} $tmp </dev/tty >/dev/tty &&\n  cat $tmp\n\nwhich you can then use like:\n\n  git cherry-pick `git log | vpipe`\n\nI know that sort of thing is not for everyone (you have to really like\nyour editor), but I thought I'd share in case it is useful.\n\n-Peff\n"},{"id":"196161","messageId":"CAFjFENp1CzepXLO+eR9A0op6ESRKCTsFLc90e1EKuw1p1A3y5w@mail.gmail.com","threadId":"31136","inReplyTo":"7vipd5s161.fsf@alter.siamese.dyndns.org","subject":"Re: A new way to get a sha1?","fromName":"Thomas Badie","fromEmail":"thomas.badie@gmail.com","sentAt":"2012-07-30T16:57:58Z","receivedAt":"2012-07-30T16:57:58Z","isPatch":false,"sender":{"key":"thomas.badie@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1281881?v=4"},"body":"2012/7/30 Junio C Hamano <gitster@pobox.com>:\n> Jan Engelhardt <jengelh@inai.de> writes:\n>\n>> On Monday 2012-07-30 14:11, Thomas Badie wrote:\n>>\n>>>Hi all,\n>>>\n>>>When I should fixup or squash a commit, I nearly never\n>>>remember how to get the sha1 of the commit I want to fixup.\n>>>Because sometimes HEAD~n is not enough, I make `git log`,\n>>>copy the sha1 of the right commit and paste it in my git\n>>>fixup command. So I wrote a perl script to avoid the usage\n>>>of the mouse.\n>>\n>> If you use screen(1), you can use the keyboard as well; it offers ^A [\n>> and ^A ] for copy, and then paste. tmux and all those screen clones\n>> probably have something similar. Maybe ratpoison-like WMs do as well.\n>> Or, you can use `git log --oneline`, look for the commit and then\n>> type the (usually) 6-char part of the hash manually, which may be faster\n>> than ^A[, moving the cursor to the copy position, marking it, etc.\n>\n> Also,\n>\n>         git show -s ':/^t1100-.*: Fix an interm'\n>\n> would work well.  It your log messages are not descriptive enough,\n> however, that may not, but that is easily fixable by training you\n> and your colleages to give a more descriptive title to each commit,\n> which will make your project better.\n\nAnother aim of this module would be to avoid writing the beginning of\nthe commit message.\n\nThanks for your proposition. I didn't know this solution.\n\n-- \nThomas \"Enki\" Badie\n"},{"id":"196165","messageId":"CAFjFENq7jXA70KJSk0U7LpAupJv3tkRAfgyMKA1RewW=ttsUdQ@mail.gmail.com","threadId":"31136","inReplyTo":"87k3xli6mn.fsf@thomas.inf.ethz.ch","subject":"Re: A new way to get a sha1?","fromName":"Thomas Badie","fromEmail":"thomas.badie@gmail.com","sentAt":"2012-07-30T17:17:00Z","receivedAt":"2012-07-30T17:17:00Z","isPatch":false,"sender":{"key":"thomas.badie@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1281881?v=4"},"body":"2012/7/30 Thomas Rast <trast@student.ethz.ch>:\n> Thomas Badie <thomas.badie@gmail.com> writes:\n>\n>> The idea is to have a perl module which run through\n>> the log history and print 10 shortlog associated with a number\n>> from 0 to 9, and a message below \"Select commit [| 0, 9 |] or\n>> next row ?\" or this kind of message with several options.\n>>\n>> So I ask to the community if this module is interesting for git.\n>> It can be integrated everywhere a sha1 is requested (git rebase,\n>> git reset, ...). IMHO, it can be an enhancement.\n>\n> I think this is too specific.  If you want full interactivity, use a\n> real interactive tool like tig.\n\nSecond suggestion for tig. I must definitely try it.\n\n> However, your post and some quick searching gave me another idea.  Bash\n> actually has features to let you edit the current command line from\n> within key bindings.  So if only we had some clever utility, let's call\n> it lineselect for lack of a better name, that let us do\n>\n>   git log --oneline <args> | lineselect\n>\n> then we could paste the selected SHA1 into the command line.  That would\n> be really neat, wouldn't it?\n>\n> I haven't found such a utility, so below is my first shot at making\n> something useful.  It has:\n>\n> * a few keybinds that should make most people happy\n> * color rendering (yay), but because of issues with the default\n>   rendering, it sets white-on-black by default\n> * an optional regex arg to select only parts of the lines\n\nVery interesting. I tried it and it is nice. I fix a little bug (\"Use of\nuninitialized...\") on my fork. I will take a look on the things that\ndon't work yet ;) I'm pretty sure that there is a lot of possible\nusage of this script.\n\n> Things that notably _don't_ work yet:\n>\n> * cursor keys (I have no idea why it doesn't match KEY_UP etc.)\n> * ANSI attributes (colors work, of sorts)\n> * Searching the next occurrence of a search string\n>\n> But you can probably guess that those aren't a huge problem for me.\n>\n> I made a little repo too, for all your forking needs:\n>\n>   https://github.com/trast/lineselect.git\n>   git://github.com/trast/lineselect.git\n\nThanks for sharing it!\n\n> Thanks for the idea :-)\n\nYou're very welcome!\n\n-- \nThomas \"Enki\" Badie\n"},{"id":"196171","messageId":"CAFjFENrBskVHYZT1rLnAYXDjUJ_2HrFR7+L1=HrEV5iOWXZt8g@mail.gmail.com","threadId":"31136","inReplyTo":"20120730165147.GD16701@sigill.intra.peff.net","subject":"Re: A new way to get a sha1?","fromName":"Thomas Badie","fromEmail":"thomas.badie@gmail.com","sentAt":"2012-07-30T17:33:01Z","receivedAt":"2012-07-30T17:33:01Z","isPatch":false,"sender":{"key":"thomas.badie@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1281881?v=4"},"body":"2012/7/30 Jeff King <peff@peff.net>:\n> On Mon, Jul 30, 2012 at 06:40:12PM +0200, Thomas Badie wrote:\n>\n>> I understand your opinion. My solution was a easier way to make your\n>> proposition about `git log --oneline`, because I don't want to copy these\n>> 6 numbers by hand. I'd prefer select the right line simply.\n>>\n>> My solution is intended for people who just use git, and whatever their\n>> environment (Unix, Windows...) because all is contained in git.\n>>\n>> But I clearly agree that there is a lot of other solutions by using external\n>> tools.  But IMHO, it is preferable that I just have to add a `-i' to a command\n>> to make this choice simply, and not having to use my WM for this kind of task.\n>\n> I am pretty mouse-averse, and I find a nice solution to these sorts of\n> interactive-selection problems is to use your editor. In its most basic\n> form, something like:\n>\n>   git log --oneline >tmp\n>   $EDITOR tmp ;# and delete everything you don't want\n>   git cherry-pick `cat tmp`\n>\n> assuming you are proficient with your editor, finding the entry you want\n> and deleting all of the unwanted lines should be just a few keystrokes.\n> And you can simplify it with a script like this:\n>\n>   $ cat `which vpipe`\n>   #!/bin/sh\n>   trap 'rm -f $tmp' 0\n>   tmp=`mktemp vpipe-XXXXXX` &&\n>   cat >$tmp &&\n>   ${EDITOR:-vi} $tmp </dev/tty >/dev/tty &&\n>   cat $tmp\n>\n> which you can then use like:\n>\n>   git cherry-pick `git log | vpipe`\n>\n> I know that sort of thing is not for everyone (you have to really like\n> your editor), but I thought I'd share in case it is useful.\n\nFor this case, I don't think I'll use it, but it shows how to use the editor\nin a replacement of an interactive tool, and it is interesting. I'd change\nvi for emacs but this is religious. I never though using my editor this way,\nand maybe one day it will be useful.\n\nThanks for your answer.\n\n-- \nThomas Badie\n"},{"id":"196178","messageId":"m2lii1rv53.fsf@igel.home","threadId":"31136","inReplyTo":"CAFjFENrBskVHYZT1rLnAYXDjUJ_2HrFR7+L1=HrEV5iOWXZt8g@mail.gmail.com","subject":"Re: A new way to get a sha1?","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-07-30T17:55:36Z","receivedAt":"2012-07-30T17:55:36Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Thomas Badie <thomas.badie@gmail.com> writes:\n\n> For this case, I don't think I'll use it, but it shows how to use the editor\n> in a replacement of an interactive tool, and it is interesting. I'd change\n> vi for emacs but this is religious.\n\nIf you use emacs anyway you could run the shell inside it, giving you\nall the power of cut-and-paste.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"196181","messageId":"CACPiFCKxYdF8G33myfjOXU31cDWrfrtedve8m89tH_tfOCZ4ng@mail.gmail.com","threadId":"31136","inReplyTo":"7vipd5s161.fsf@alter.siamese.dyndns.org","subject":"Re: A new way to get a sha1?","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2012-07-30T18:16:30Z","receivedAt":"2012-07-30T18:16:30Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On Mon, Jul 30, 2012 at 11:45 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>         git show -s ':/^t1100-.*: Fix an interm'\n\nThat doesn't work for me (git 1.7.10.4 as per Fedora 18 rpms) in\ngit.git. But the idea is sound -- git can give you the sha1 trivially.\nYou don't need additional glue.\n\nBut any ref definition can be turned into a sha1 with this snippet:\n\n    git show --pretty=format:%H HEAD\n\nIf you want to get the last 10 sha1s, use the same \"pretty\" with git log\n\n   git log --pretty=format:%H HEAD | head\n\nThis is all predicated on passing the info to something else. For git\ncommands, you can always use the rich ref notation git supports.\n\ncheers,\n\n\nm\n-- \n martin.langhoff@gmail.com\n martin@laptop.org -- Software Architect - OLPC\n - ask interesting questions\n - don't get distracted with shiny stuff  - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"},{"id":"196182","messageId":"7vboixqf08.fsf@alter.siamese.dyndns.org","threadId":"31136","inReplyTo":"CACPiFCKxYdF8G33myfjOXU31cDWrfrtedve8m89tH_tfOCZ4ng@mail.gmail.com","subject":"Re: A new way to get a sha1?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-30T18:29:27Z","receivedAt":"2012-07-30T18:29:27Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Langhoff <martin.langhoff@gmail.com> writes:\n\n> On Mon, Jul 30, 2012 at 11:45 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>>         git show -s ':/^t1100-.*: Fix an interm'\n>\n> That doesn't work for me (git 1.7.10.4 as per Fedora 18 rpms) in\n> git.git. But the idea is sound -- git can give you the sha1 trivially.\n> You don't need additional glue.\n\nThe idea was that you do not have to give abbreviated SHA-1 to Git\nin the first place.\n\nWhat doesn't work?  My copy of v1.7.10.1 seems to grok the above\njust fine.\n"},{"id":"196183","messageId":"m2hasprt1l.fsf@igel.home","threadId":"31136","inReplyTo":"CACPiFCKxYdF8G33myfjOXU31cDWrfrtedve8m89tH_tfOCZ4ng@mail.gmail.com","subject":"Re: A new way to get a sha1?","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-07-30T18:40:54Z","receivedAt":"2012-07-30T18:40:54Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Martin Langhoff <martin.langhoff@gmail.com> writes:\n\n> But any ref definition can be turned into a sha1 with this snippet:\n>\n>     git show --pretty=format:%H HEAD\n\n      git rev-parse HEAD\n\n> If you want to get the last 10 sha1s, use the same \"pretty\" with git log\n>\n>    git log --pretty=format:%H HEAD | head\n\n     git rev-list -n 10 HEAD\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"196184","messageId":"CACPiFCLw6CqteJfPjXE86deDuvAH-Bua8pKks=bDv1x6RtxxYA@mail.gmail.com","threadId":"31136","inReplyTo":"7vboixqf08.fsf@alter.siamese.dyndns.org","subject":"Re: A new way to get a sha1?","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2012-07-30T18:42:33Z","receivedAt":"2012-07-30T18:42:33Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On Mon, Jul 30, 2012 at 2:29 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> The idea was that you do not have to give abbreviated SHA-1 to Git\n> in the first place.\n\nAh, sorry, I didn't get _that_ point. I thought you were trying to\ndemo a way to get a sha1.\n\n> What doesn't work?  My copy of v1.7.10.1 seems to grok the above\n> just fine.\n\nGaah, it barfed at first, works now. My apologies. I may have\nmishandled the copy to the terminal -- dropped or corrupted the\nsingle-quotes.\n\ncheers,\n\n\nm\n-- \n martin.langhoff@gmail.com\n martin@laptop.org -- Software Architect - OLPC\n - ask interesting questions\n - don't get distracted with shiny stuff  - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"}]}