{"thread":{"id":"13572","subject":"Git GUI vs interactive post-commit hooks","startedAt":"2008-05-19T10:48:14Z","lastAt":"2008-05-22T15:12:46Z","messageCount":9,"participants":["Alexander Gladysh","Björn Steinbrink","Alex Riesen","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"77266","messageId":"c6c947f60805190348g3395f8degae81963b402856b6@mail.gmail.com","threadId":"13572","inReplyTo":null,"subject":"Git GUI vs interactive post-commit hooks","fromName":"Alexander Gladysh","fromEmail":"agladysh@gmail.com","sentAt":"2008-05-19T10:48:14Z","receivedAt":"2008-05-19T10:48:14Z","isPatch":false,"sender":{"key":"agladysh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38239?v=4"},"body":"Hi, list!\n\n$ git --version\ngit version 1.5.5.1\n\nI have a post-commit hook which does backups for me:\n\n  username=agladysh\n  for name in `git branch | cut -b3-`\n  do\n    remote=$username-$name\n    echo pushing $name as $remote\n    git push backup +$name:refs/heads/$remote\n  done\n\nThe backup repo is behind ssh. Recently I have put password on my ssh\nkey and post-commit hook ask me for password once for each branch.\nThis makes unhappy commit process from Git GUI -- after I shut it\ndown, there are multiple ssh key password prompts in the shell from\nwhere I launched it, and it does not display any input I enter.\n\nAny advice? I do want to input password for my key each time I use it.\n\nThanks in advance,\nAlexander.\n"},{"id":"77269","messageId":"20080519131942.GA5526@atjola.homenet","threadId":"13572","inReplyTo":"c6c947f60805190348g3395f8degae81963b402856b6@mail.gmail.com","subject":"Re: Git GUI vs interactive post-commit hooks","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-05-19T13:19:42Z","receivedAt":"2008-05-19T13:19:42Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.05.19 14:48:14 +0400, Alexander Gladysh wrote:\n> Hi, list!\n> \n> $ git --version\n> git version 1.5.5.1\n> \n> I have a post-commit hook which does backups for me:\n> \n>   username=agladysh\n>   for name in `git branch | cut -b3-`\n>   do\n>     remote=$username-$name\n>     echo pushing $name as $remote\n>     git push backup +$name:refs/heads/$remote\n>   done\n\nIsn't that what \"git push --all\" does? And that will only ask for a\npassword once, not for every branch.\n\n> The backup repo is behind ssh. Recently I have put password on my ssh\n> key and post-commit hook ask me for password once for each branch.\n> This makes unhappy commit process from Git GUI -- after I shut it\n> down, there are multiple ssh key password prompts in the shell from\n> where I launched it, and it does not display any input I enter.\n> \n> Any advice? I do want to input password for my key each time I use it.\n\nFor a graphical tool, you might want to use something like\ngtk-led-askpass, which shows a window with a password prompt. SSH will\nmake use of it if SSH_ASKPASS contains its path _and_ ssh is not started\nfrom a terminal. Unfortunately, the latter is probably not true for git\ngui most of the time.\n\nOne way hack around this is to do \"setsid git push ...\" in your\npost-commit hook. But that will break if you have no X or no tool for\nSSH_ASKPASS.\n\nAnother really hackish work-around is to\nreplace:\n exec 'wish' \"$argv0\" -- \"$@\"\nwith\n exec 'setsid' 'wish' \"$argv0\" -- \"$@\"\n\nin git-gui. Git gui will then get its own session, detached from the\nterminal and ssh will start using SSH_ASKPASS. That at least won't break\nwhen you're not running X (simply because you won't be running git gui\nthen ;-)), but doesn't feel smart either.\n\nMaybe someone else can come up with a sane solution that makes git gui\nmore SSH_ASKPASS-friendly.\n\nBjörn\n"},{"id":"77270","messageId":"c6c947f60805190642x7d44ef04h4090cbb687de69e@mail.gmail.com","threadId":"13572","inReplyTo":"20080519131942.GA5526@atjola.homenet","subject":"Re: Git GUI vs interactive post-commit hooks","fromName":"Alexander Gladysh","fromEmail":"agladysh@gmail.com","sentAt":"2008-05-19T13:42:05Z","receivedAt":"2008-05-19T13:42:05Z","isPatch":false,"sender":{"key":"agladysh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38239?v=4"},"body":"On Mon, May 19, 2008 at 5:19 PM, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:\n> On 2008.05.19 14:48:14 +0400, Alexander Gladysh wrote:\n>> Hi, list!\n>>\n>> $ git --version\n>> git version 1.5.5.1\n>>\n>> I have a post-commit hook which does backups for me:\n>>\n>>   username=agladysh\n>>   for name in `git branch | cut -b3-`\n>>   do\n>>     remote=$username-$name\n>>     echo pushing $name as $remote\n>>     git push backup +$name:refs/heads/$remote\n>>   done\n>\n> Isn't that what \"git push --all\" does? And that will only ask for a\n> password once, not for every branch.\n\ngit push --all would not rename my branches... But, I guess, this can\nbe done as preparation step somehow.\n\n>> The backup repo is behind ssh. Recently I have put password on my ssh\n>> key and post-commit hook ask me for password once for each branch.\n>> This makes unhappy commit process from Git GUI -- after I shut it\n>> down, there are multiple ssh key password prompts in the shell from\n>> where I launched it, and it does not display any input I enter.\n>>\n>> Any advice? I do want to input password for my key each time I use it.\n>\n> For a graphical tool, you might want to use something like\n> gtk-led-askpass, which shows a window with a password prompt. SSH will\n> make use of it if SSH_ASKPASS contains its path _and_ ssh is not started\n> from a terminal. Unfortunately, the latter is probably not true for git\n> gui most of the time.\n\n<Useful advice regarding how to solve SSH_ASKPASS issue skipped.>\n\nThanks, I would try that. I'm mostly working from X, so lack of X\nshould be not an issue... However I'd like to avoid patching my local\ncopy of git as much as possible. :-)\n\n> Maybe someone else can come up with a sane solution that makes git gui\n> more SSH_ASKPASS-friendly.\n\nThat would be great.\n\nThank you,\nAlexander.\n"},{"id":"77271","messageId":"20080519141112.GA12304@atjola.homenet","threadId":"13572","inReplyTo":"c6c947f60805190642x7d44ef04h4090cbb687de69e@mail.gmail.com","subject":"Re: Git GUI vs interactive post-commit hooks","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-05-19T14:11:12Z","receivedAt":"2008-05-19T14:11:12Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.05.19 17:42:05 +0400, Alexander Gladysh wrote:\n> On Mon, May 19, 2008 at 5:19 PM, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:\n> > On 2008.05.19 14:48:14 +0400, Alexander Gladysh wrote:\n> >> Hi, list!\n> >>\n> >> $ git --version\n> >> git version 1.5.5.1\n> >>\n> >> I have a post-commit hook which does backups for me:\n> >>\n> >>   username=agladysh\n> >>   for name in `git branch | cut -b3-`\n> >>   do\n> >>     remote=$username-$name\n> >>     echo pushing $name as $remote\n> >>     git push backup +$name:refs/heads/$remote\n> >>   done\n> >\n> > Isn't that what \"git push --all\" does? And that will only ask for a\n> > password once, not for every branch.\n> \n> git push --all would not rename my branches... But, I guess, this can\n> be done as preparation step somehow.\n\nOh, oops, didn't notice the $remote stuff, sorry.\n\n> >> The backup repo is behind ssh. Recently I have put password on my ssh\n> >> key and post-commit hook ask me for password once for each branch.\n> >> This makes unhappy commit process from Git GUI -- after I shut it\n> >> down, there are multiple ssh key password prompts in the shell from\n> >> where I launched it, and it does not display any input I enter.\n> >>\n> >> Any advice? I do want to input password for my key each time I use it.\n> >\n> > For a graphical tool, you might want to use something like\n> > gtk-led-askpass, which shows a window with a password prompt. SSH will\n> > make use of it if SSH_ASKPASS contains its path _and_ ssh is not started\n> > from a terminal. Unfortunately, the latter is probably not true for git\n> > gui most of the time.\n> \n> <Useful advice regarding how to solve SSH_ASKPASS issue skipped.>\n> \n> Thanks, I would try that. I'm mostly working from X, so lack of X\n> should be not an issue... However I'd like to avoid patching my local\n> copy of git as much as possible. :-)\n\nWell, the \"lack of X\" issue only arises if you patch your post-commit\nhook. Adding setsid to the git push command was supposed to happen there\n;-) You could probably even make that conditional, so that setsid is\nonly used then DISPLAY is set, then it should even work when there's no\nX, but still be annoying when you commit from a terminal... (At least I\nwould prefer to enter the password in the terminal then).\n\nBjörn\n"},{"id":"77356","messageId":"20080520223158.GB13123@steel.home","threadId":"13572","inReplyTo":"20080519131942.GA5526@atjola.homenet","subject":"Re: Git GUI vs interactive post-commit hooks","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-05-20T22:31:58Z","receivedAt":"2008-05-20T22:31:58Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Bj?rn Steinbrink, Mon, May 19, 2008 15:19:42 +0200:\n> On 2008.05.19 14:48:14 +0400, Alexander Gladysh wrote:\n> > \n> > Any advice? I do want to input password for my key each time I use it.\n> \n> For a graphical tool, you might want to use something like\n> gtk-led-askpass, which shows a window with a password prompt. SSH will\n> make use of it if SSH_ASKPASS contains its path _and_ ssh is not started\n> from a terminal. Unfortunately, the latter is probably not true for git\n> gui most of the time.\n\nRedirect stdin from /dev/null\n"},{"id":"77358","messageId":"20080520230204.GA5383@atjola.homenet","threadId":"13572","inReplyTo":"20080520223158.GB13123@steel.home","subject":"Re: Git GUI vs interactive post-commit hooks","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-05-20T23:02:04Z","receivedAt":"2008-05-20T23:02:04Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.05.21 00:31:58 +0200, Alex Riesen wrote:\n> Bj?rn Steinbrink, Mon, May 19, 2008 15:19:42 +0200:\n> > On 2008.05.19 14:48:14 +0400, Alexander Gladysh wrote:\n> > > \n> > > Any advice? I do want to input password for my key each time I use it.\n> > \n> > For a graphical tool, you might want to use something like\n> > gtk-led-askpass, which shows a window with a password prompt. SSH will\n> > make use of it if SSH_ASKPASS contains its path _and_ ssh is not started\n> > from a terminal. Unfortunately, the latter is probably not true for git\n> > gui most of the time.\n> \n> Redirect stdin from /dev/null\n\nDoes that actually work for you? It didn't work for me, because ssh then\nsimply goes and opens /dev/tty to ask for the password.\n\n$ ssh -V\nOpenSSH_4.7p1 Debian-10, OpenSSL 0.9.8g 19 Oct 2007\n\nBjörn\n"},{"id":"77359","messageId":"20080520231631.GB22934@sigill.intra.peff.net","threadId":"13572","inReplyTo":"20080520230204.GA5383@atjola.homenet","subject":"Re: Git GUI vs interactive post-commit hooks","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-05-20T23:16:31Z","receivedAt":"2008-05-20T23:16:31Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 21, 2008 at 01:02:04AM +0200, Björn Steinbrink wrote:\n\n> > Redirect stdin from /dev/null\n> \n> Does that actually work for you? It didn't work for me, because ssh then\n> simply goes and opens /dev/tty to ask for the password.\n> \n> $ ssh -V\n> OpenSSH_4.7p1 Debian-10, OpenSSL 0.9.8g 19 Oct 2007\n\nI had to perform this same task a few weeks ago, and ended up using\n'setsid' to get rid of the controlling tty. You may also need to unset\nSSH_ASKPASS and DISPLAY.\n\n-Peff\n"},{"id":"77466","messageId":"20080522125301.GD3206@steel.home","threadId":"13572","inReplyTo":"20080520230204.GA5383@atjola.homenet","subject":"Re: Git GUI vs interactive post-commit hooks","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-05-22T12:53:01Z","receivedAt":"2008-05-22T12:53:01Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Björn Steinbrink, Wed, May 21, 2008 01:02:04 +0200:\n> On 2008.05.21 00:31:58 +0200, Alex Riesen wrote:\n> > Bj?rn Steinbrink, Mon, May 19, 2008 15:19:42 +0200:\n> > > On 2008.05.19 14:48:14 +0400, Alexander Gladysh wrote:\n> > > > \n> > > > Any advice? I do want to input password for my key each time I use it.\n> > > \n> > > For a graphical tool, you might want to use something like\n> > > gtk-led-askpass, which shows a window with a password prompt. SSH will\n> > > make use of it if SSH_ASKPASS contains its path _and_ ssh is not started\n> > > from a terminal. Unfortunately, the latter is probably not true for git\n> > > gui most of the time.\n> > \n> > Redirect stdin from /dev/null\n> \n> Does that actually work for you? It didn't work for me, because ssh then\n> simply goes and opens /dev/tty to ask for the password.\n> \n> $ ssh -V\n> OpenSSH_4.7p1 Debian-10, OpenSSL 0.9.8g 19 Oct 2007\n> \n\nNo :( I took this information from sshs manpage:\n\n     SSH_ASKPASS           If ssh needs a passphrase, it will read the\n                           passphrase from the current terminal if it was run\n                           from a terminal.  If ssh does not have a terminal\n                           associated with it but DISPLAY and SSH_ASKPASS are\n                           set, it will execute the program specified by\n                           SSH_ASKPASS and open an X11 window to read the\n                           passphrase.  This is particularly useful when call‐\n                           ing ssh from a .xsession or related script.  (Note\n                           that on some machines it may be necessary to redi‐\n                           rect the input from /dev/null to make this work.)\n"},{"id":"77473","messageId":"20080522151246.GA9765@atjola.homenet","threadId":"13572","inReplyTo":"20080522125301.GD3206@steel.home","subject":"Re: Git GUI vs interactive post-commit hooks","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-05-22T15:12:46Z","receivedAt":"2008-05-22T15:12:46Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.05.22 14:53:01 +0200, Alex Riesen wrote:\n> Björn Steinbrink, Wed, May 21, 2008 01:02:04 +0200:\n> > On 2008.05.21 00:31:58 +0200, Alex Riesen wrote:\n> > > Bj?rn Steinbrink, Mon, May 19, 2008 15:19:42 +0200:\n> > > > On 2008.05.19 14:48:14 +0400, Alexander Gladysh wrote:\n> > > > > \n> > > > > Any advice? I do want to input password for my key each time I use it.\n> > > > \n> > > > For a graphical tool, you might want to use something like\n> > > > gtk-led-askpass, which shows a window with a password prompt. SSH will\n> > > > make use of it if SSH_ASKPASS contains its path _and_ ssh is not started\n> > > > from a terminal. Unfortunately, the latter is probably not true for git\n> > > > gui most of the time.\n> > > \n> > > Redirect stdin from /dev/null\n> > \n> > Does that actually work for you? It didn't work for me, because ssh then\n> > simply goes and opens /dev/tty to ask for the password.\n> > \n> > $ ssh -V\n> > OpenSSH_4.7p1 Debian-10, OpenSSL 0.9.8g 19 Oct 2007\n> > \n> \n> No :( I took this information from sshs manpage:\n> \n>      SSH_ASKPASS           If ssh needs a passphrase, it will read the\n>                            passphrase from the current terminal if it was run\n>                            from a terminal.  If ssh does not have a terminal\n>                            associated with it but DISPLAY and SSH_ASKPASS are\n>                            set, it will execute the program specified by\n>                            SSH_ASKPASS and open an X11 window to read the\n>                            passphrase.  This is particularly useful when call‐\n>                            ing ssh from a .xsession or related script.  (Note\n>                            that on some machines it may be necessary to redi‐\n>                            rect the input from /dev/null to make this work.)\n\nYeah, that got me trying the redirection, too. But the \"If ssh does not\nhave a terminal associated\" part is actually what counts, it seems.\nBecause ssh falls back to /dev/tty if stdin doesn't work. Guess the\nstdin redirect might just be required in some cases, where it would use\n/dev/stdin directly, so you force it to try /dev/tty and then use\nSSH_ASKPASS.\n\nBjörn\n"}]}