{"thread":{"id":"4484","subject":"Thoughts on adding another hook to git","startedAt":"2006-06-12T18:27:13Z","lastAt":"2006-06-13T18:41:06Z","messageCount":9,"participants":["David Kowis","Yakov Lerner","Nikolai Weibull","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"21663","messageId":"448DB201.5090208@shlrm.org","threadId":"4484","inReplyTo":null,"subject":"Thoughts on adding another hook to git","fromName":"David Kowis","fromEmail":"dkowis@shlrm.org","sentAt":"2006-06-12T18:27:13Z","receivedAt":"2006-06-12T18:27:13Z","isPatch":false,"sender":{"key":"dkowis@shlrm.org","avatar":"https://gravatar.com/avatar/2ebebf02e2dc139286a4ebb90ceda4a07efe0fdb8c3a4c24bc7c1379a1effb4a?d=mp&s=160"},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA512\n\nI'd like to be able to modify the commit message before it ends up in\nthe $EDITOR. This is a fairly trivial thing to implement:\nCall ${GIT_DIR}/hooks/pre-editor on COMMIT_MESSAGE before opening it in\n$EDITOR.\n\nMy question to you all is should I set it up so that the hook only opens\nwhen the $EDITOR is actually being called? (really easy)\nOr, do I set it up so that the hook always happens. In which case it's\nsimilar to the commit-msg hook already, just happens before the message\ninstead of after.\n\nThanks,\n- --\nDavid Kowis\n\nISO Team Lead - www.sourcemage.org\nSource Mage GNU/Linux\n\nProgress isn't made by early risers. It's made by lazy men trying to\nfind easier ways to do something.\n  - Robert Heinlein\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.2 (MingW32)\n\niQGVAwUBRI2yAMnf+vRw63ObAQpNSgv+OCXYSDlW96K9M5QZvSaEbdZOGorYZg5Y\nRSh9WUXS2ribYRr1TbplD0Fp4vGnG8CB6qvr2QF8vP3tbEMjnwk4LobeWaUtK2Kn\nHja3TgIUPWkzHMLleToe5o99r8v/6LFf9rkBxvFw3TMkuxsFS/lFlxy1eRa43rvd\nSkod2cA7RWus1IFJcbDKNonjhJkVkHylSMjT8iVQDbgY0hg7PEy2ZW3XB0MJJRZC\nlLsDDIJ4msPCXSx/lDRGaJj+m7IrvUgnEDzkX0jTT8DeZqnlC8nRM/2dOS72b/5w\ngIBYu49DvTL8ynod2mmYTyBynfRpVxPjxnXbubn/M+N+0WCTXIUTPCbyW2MOscjA\npFe6/S1qKaTqc06VBDabYxdvGrHG6v+KkaJhu2XoLOHWVoBblobBBNrpIkA6GNqz\nH7JHNJDF+JbshlW2aU2HazDINRfD/AfrJmDx4Xn91qAKiegyO3wRA1rM6a0LEpun\nzg3haF3l0rfBEdFpz21gNQbYxNHaRkwg\n=Rxm/\n-----END PGP SIGNATURE-----\n"},{"id":"21668","messageId":"f36b08ee0606121206k62242354k13671f95da6b1418@mail.gmail.com","threadId":"4484","inReplyTo":"448DB201.5090208@shlrm.org","subject":"Re: Thoughts on adding another hook to git","fromName":"Yakov Lerner","fromEmail":"iler.ml@gmail.com","sentAt":"2006-06-12T19:06:11Z","receivedAt":"2006-06-12T19:06:11Z","isPatch":false,"sender":{"key":"iler.ml@gmail.com","avatar":null},"body":"On 6/12/06, David Kowis <dkowis@shlrm.org> wrote:\n> I'd like to be able to modify the commit message before it ends up in\n> the $EDITOR.\n\nCan't you define $EDITOR to point to some script\nwhich modifies the file as you wish then calls the\nreal editor on it ?\n\nYakov\n"},{"id":"21671","messageId":"448DBC2B.1070807@shlrm.org","threadId":"4484","inReplyTo":"f36b08ee0606121206k62242354k13671f95da6b1418@mail.gmail.com","subject":"Re: Thoughts on adding another hook to git","fromName":"David Kowis","fromEmail":"dkowis@shlrm.org","sentAt":"2006-06-12T19:10:35Z","receivedAt":"2006-06-12T19:10:35Z","isPatch":false,"sender":{"key":"dkowis@shlrm.org","avatar":"https://gravatar.com/avatar/2ebebf02e2dc139286a4ebb90ceda4a07efe0fdb8c3a4c24bc7c1379a1effb4a?d=mp&s=160"},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA512\n\nYakov Lerner wrote:\n> On 6/12/06, David Kowis <dkowis@shlrm.org> wrote:\n>> I'd like to be able to modify the commit message before it ends up in\n>> the $EDITOR.\n> \n> Can't you define $EDITOR to point to some script\n> which modifies the file as you wish then calls the\n> real editor on it ?\n> \n\nI could, but then anything else that uses $EDITOR would also be affected\nin the same way... Which would produce interesting results.\n\n- --\nDavid Kowis\n\nISO Team Lead - www.sourcemage.org\nSource Mage GNU/Linux\n\nProgress isn't made by early risers. It's made by lazy men trying to\nfind easier ways to do something.\n  - Robert Heinlein\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.2 (MingW32)\n\niQGVAwUBRI28K8nf+vRw63ObAQoKPgv9EvwbDkGmct7IZGFMydea+HlIMWR+Jyla\nWHYnCN353Hw+WbOIvnTvlJrI1R+zSYIu2tDhZ2P/2czyWyja8HQHjGhTXbBInILX\nT4ODPwZ55od4uDi1arnHgRpJwhLeGIU+1Wxc8k70tszWj2gb6sIGMHcK9LhzZ+Sf\nlEY6iGF74TE3gyQsj78smxL/COvNjzoCWY4AieIVxtu7b1shb7lZXbnkfcKhs82L\n0bdmHKri7999nxgWnmdyaDi9RuYOKinc/YhrKDrvY2GB5c8BQHgpFMDR/17oTREL\nPTmAJwFs8dAAalGmPAajZY1gXrqo/lVb4JPK4b2QboEC8SGpFwcq4jtHCr/s2mQd\nuNINnZ62+dxgRxk9koW2QZeh7hPB8rFcIufUhUC19P0+UWv5TDuKie/mR1U6uZNN\nBfTIj/1AI5+l9kCJS+om9o8P1m2wPW4MsP2XaqatInUz9YXn14zrjcKTZnCuIMvw\nmqrBlfI7L2KEsoL4ywJsb4ATVz7M6G0I\n=IFOu\n-----END PGP SIGNATURE-----\n"},{"id":"21673","messageId":"f36b08ee0606121218s6cdcfec2i42482ed5284a45e3@mail.gmail.com","threadId":"4484","inReplyTo":"448DBC2B.1070807@shlrm.org","subject":"Re: Thoughts on adding another hook to git","fromName":"Yakov Lerner","fromEmail":"iler.ml@gmail.com","sentAt":"2006-06-12T19:18:53Z","receivedAt":"2006-06-12T19:18:53Z","isPatch":false,"sender":{"key":"iler.ml@gmail.com","avatar":null},"body":"On 6/12/06, David Kowis <dkowis@shlrm.org> wrote:\n> -----BEGIN PGP SIGNED MESSAGE-----\n> Hash: SHA512\n>\n> Yakov Lerner wrote:\n> > On 6/12/06, David Kowis <dkowis@shlrm.org> wrote:\n> >> I'd like to be able to modify the commit message before it ends up in\n> >> the $EDITOR.\n> >\n> > Can't you define $EDITOR to point to some script\n> > which modifies the file as you wish then calls the\n> > real editor on it ?\n> >\n>\n> I could, but then anything else that uses $EDITOR would also be affected\n> in the same way... Which would produce interesting results.\n\ngit-commit sure creates those temp files with\nspecific naming in specific dir. You could check for\nthat in EDITOR script. In the script, you could even check\nthe name of the parent process.\n\nYakov\n"},{"id":"21674","messageId":"448DBEEB.3000308@shlrm.org","threadId":"4484","inReplyTo":"f36b08ee0606121218s6cdcfec2i42482ed5284a45e3@mail.gmail.com","subject":"Re: Thoughts on adding another hook to git","fromName":"David Kowis","fromEmail":"dkowis@shlrm.org","sentAt":"2006-06-12T19:22:19Z","receivedAt":"2006-06-12T19:22:19Z","isPatch":false,"sender":{"key":"dkowis@shlrm.org","avatar":"https://gravatar.com/avatar/2ebebf02e2dc139286a4ebb90ceda4a07efe0fdb8c3a4c24bc7c1379a1effb4a?d=mp&s=160"},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA512\n\nYakov Lerner wrote:\n> On 6/12/06, David Kowis <dkowis@shlrm.org> wrote:\n>> -----BEGIN PGP SIGNED MESSAGE-----\n>> Hash: SHA512\n>>\n>> Yakov Lerner wrote:\n>> > On 6/12/06, David Kowis <dkowis@shlrm.org> wrote:\n>> >> I'd like to be able to modify the commit message before it ends up in\n>> >> the $EDITOR.\n>> >\n>> > Can't you define $EDITOR to point to some script\n>> > which modifies the file as you wish then calls the\n>> > real editor on it ?\n>> >\n>>\n>> I could, but then anything else that uses $EDITOR would also be affected\n>> in the same way... Which would produce interesting results.\n> \n> git-commit sure creates those temp files with\n> specific naming in specific dir. You could check for\n> that in EDITOR script. In the script, you could even check\n> the name of the parent process.\n> \n\nThis is true. However, I'd be running that script every time something\ninvoked $EDITOR. And some people may not like that solution. I'm\nthinking that more than just I will like to use this pre-edit hook.\nEspecially in the distro I'm helping develop.\n\n\n- --\nDavid Kowis\n\nISO Team Lead - www.sourcemage.org\nSource Mage GNU/Linux\n\nProgress isn't made by early risers. It's made by lazy men trying to\nfind easier ways to do something.\n  - Robert Heinlein\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.2 (MingW32)\n\niQGVAwUBRI2+68nf+vRw63ObAQo6Kwv/bmLf8f54lm7sXekww8olFwT3SkE8orHk\nBozzIyW8foz+FLtVbjQQbbGw1RgLrL5zPn+De+BM3LwXabhqnsVca2KpQVMkLaqx\naJwjn2JvL6ujG3ponuCCPTk5VhzU0C/Su15eIMa86O2EFu6Y0HBhw/hOnyEWJiYa\ntOxPETizJHD1YbneoTJmu+tQFaKbjAD/3tUMDkQBp9h1QkbZHD5LQUjozepLZplY\nPfOvZIP9fT6GDsK5SuweGrYZHjzuV0RlrwN191No3FsJMMX7+PQ85MBvj1p/xJG7\nVO+z33+IYPascpm/3NdpjdtKAh72+rfW5OUd8FN1ISwPtY9dJeh5zaaCTB+oEqL4\n56pchLL33SFphOO5//YwHcwgX61tPK0stsVpjfdQHEjz8BHNSoBhZw3lw/AvO+63\nUhiA3rjiIFrYe9piJHlX+IxoNo5OaLJNO2KjV9k15+0FxSzbKPn3Pt2Ee90ootEn\n8NzHFVoyOWnt5mPM+jQr4DsPgrikeUaO\n=3hwD\n-----END PGP SIGNATURE-----\n"},{"id":"21711","messageId":"dbfc82860606122329w77c566evb94ca79081a0a057@mail.gmail.com","threadId":"4484","inReplyTo":"448DBEEB.3000308@shlrm.org","subject":"Re: Thoughts on adding another hook to git","fromName":"Nikolai Weibull","fromEmail":"now@bitwi.se","sentAt":"2006-06-13T06:29:00Z","receivedAt":"2006-06-13T06:29:00Z","isPatch":false,"sender":{"key":"now@bitwi.se","avatar":"https://gravatar.com/avatar/d9242f067845cf9a72be23e4213c3b6e53492178e5df97372088a441af846133?d=mp&s=160"},"body":"On 6/12/06, David Kowis <dkowis@shlrm.org> wrote:\n> Yakov Lerner wrote:\n\n> > git-commit sure creates those temp files with\n> > specific naming in specific dir. You could check for\n> > that in EDITOR script. In the script, you could even check\n> > the name of the parent process.\n\n> This is true. However, I'd be running that script every time something\n> invoked $EDITOR. And some people may not like that solution. I'm\n> thinking that more than just I will like to use this pre-edit hook.\n> Especially in the distro I'm helping develop.\n\nPerhaps you could tell us what editor you are using.  That way we may\nprovide additional solutions.\n\n  nikolai\n"},{"id":"21716","messageId":"448EB7B6.4020708@shlrm.org","threadId":"4484","inReplyTo":"dbfc82860606122329w77c566evb94ca79081a0a057@mail.gmail.com","subject":"Re: Thoughts on adding another hook to git","fromName":"David Kowis","fromEmail":"dkowis@shlrm.org","sentAt":"2006-06-13T13:03:50Z","receivedAt":"2006-06-13T13:03:50Z","isPatch":false,"sender":{"key":"dkowis@shlrm.org","avatar":"https://gravatar.com/avatar/2ebebf02e2dc139286a4ebb90ceda4a07efe0fdb8c3a4c24bc7c1379a1effb4a?d=mp&s=160"},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA512\n\nNikolai Weibull wrote:\n> On 6/12/06, David Kowis <dkowis@shlrm.org> wrote:\n>> Yakov Lerner wrote:\n> \n>> > git-commit sure creates those temp files with\n>> > specific naming in specific dir. You could check for\n>> > that in EDITOR script. In the script, you could even check\n>> > the name of the parent process.\n> \n>> This is true. However, I'd be running that script every time something\n>> invoked $EDITOR. And some people may not like that solution. I'm\n>> thinking that more than just I will like to use this pre-edit hook.\n>> Especially in the distro I'm helping develop.\n> \n> Perhaps you could tell us what editor you are using.  That way we may\n> provide additional solutions.\n> \n\nI'm using vim. But that's irrelevant with what I'm trying to do.\n\nPerhaps I need to explain more:\n\nIn SourceMage, we have a collection of scripts, the grimoire, that\ncontain the little bits of instructions on how to build and install all\nthe software. 99% of the time most commits are based in one directory.\nFor example:\nI just updated the abook spell (A spell is that collection of\ninstructions I mentioned earlier.)\n\nI modified two files. DETAILS and HISTORY.\nDETAILS contains the version information, and a source hash to verify\ndownloads (and a bit of other stuff, but it's not important). HISTORY is\njust a changelog. Now I do `git commit .`\nI get:\n\n  1 # Explicit paths specified without -i nor -o; assuming --only paths...\n  2 #\n  3 # Updated but not checked in:\n  4 #   (will commit)\n  5 #\n  6 #   modified: mail/abook/DETAILS\n  7 #   modified: mail/abook/HISTORY\n\nWhat I'd like to be able to do is have that \"abook\" directory name\nautomatically added to the top of my commit message before it gets into\nthe editor. I can do this with a script (echo ${PWD##*/}) but it'd need\nto be a hook before the editor shows up.\n\n  1 abook:\n  2 # Explicit paths specified without -i nor -o; assuming --only paths...\n  3 #\n  4 # Updated but not checked in:\n  5 #   (will commit)\n  6 #\n  7 #   modified: mail/abook/DETAILS\n  8 #   modified: mail/abook/HISTORY\n\nIt helps in the short log (git log) for describing for which spell the\nlog refers. Although it could be done with an EDITOR script I don't\nthink that's the best solution. It's certainly not a good solution to\ngive out to a lot of people. Most of the changes to our grimoire are\nlike this one, so this would be extremely useful to us.\n\nHope that clears things up a bit,\n- --\nDavid Kowis\n\nISO Team Lead - www.sourcemage.org\nSource Mage GNU/Linux\n\nProgress isn't made by early risers. It's made by lazy men trying to\nfind easier ways to do something.\n  - Robert Heinlein\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.2 (MingW32)\n\niQGVAwUBRI63tsnf+vRw63ObAQqvqAv/QkyEi4/wIDo+sQGMPkXhj/e7yMDXbVLm\nXYaVhlxOG3rXfaEu6ecdjm8b6h4UYCMFnhYKUiDqD42LlEdofCIOecGULyP5Nx9q\nJAL8BaZpq4MwRQt4HiX9oLQBTIW2ZcD9Fg5ZqFUL3QWFbjednbEl+M8/41JGFL4s\nXpvIcKHfAy90qdG5QrgsHdQTAS6JG+9mFmyi4d0wlDWBh4WoutfEfL/nwbH79d2B\nUdq6j/SIy0dmsbjNmzJnPYn5IVrFYGez4y5bW7LDpO5ddf4027iz9mNb8hd0wCzL\nakh1f4xQQ178iaFz4y60TTmNavxswRmdoKTghRKet0MXTtBTUXe0TUJ5vNOtKODz\n5MWu9M5/olCcLqlb7L6wnvqJ9HnJTvAEAUQpvKztQcC2Uy2XkpznW3XmeEK50CLU\nVQjxSzubUfXDxkf/hS1nY3WKL3UuQoGWVDmL2Maxno+Kwb3YoyW5+etvYvfoqNT7\nVi7bpiX6fPVF/r6ogATzqla2EFLsta1f\n=m3vG\n-----END PGP SIGNATURE-----\n"},{"id":"21719","messageId":"dbfc82860606130826jd9ba61fx26d0b3e42d68c93a@mail.gmail.com","threadId":"4484","inReplyTo":"448EB7B6.4020708@shlrm.org","subject":"Re: Thoughts on adding another hook to git","fromName":"Nikolai Weibull","fromEmail":"now@bitwi.se","sentAt":"2006-06-13T15:26:34Z","receivedAt":"2006-06-13T15:26:34Z","isPatch":false,"sender":{"key":"now@bitwi.se","avatar":"https://gravatar.com/avatar/d9242f067845cf9a72be23e4213c3b6e53492178e5df97372088a441af846133?d=mp&s=160"},"body":"On 6/13/06, David Kowis <dkowis@shlrm.org> wrote:\n> I'm using vim.\n\n>   1 # Explicit paths specified without -i nor -o; assuming --only paths...\n>   2 #\n>   3 # Updated but not checked in:\n>   4 #   (will commit)\n>   5 #\n>   6 #   modified: mail/abook/DETAILS\n>   7 #   modified: mail/abook/HISTORY\n>\n> What I'd like to be able to do is have that \"abook\" directory name\n> automatically added to the top of my commit message before it gets into\n> the editor. I can do this with a script (echo ${PWD##*/}) but it'd need\n> to be a hook before the editor shows up.\n\nautocmd BufRead .git/COMMIT_MSG call setline(1, expand('%:p:h:h:t'))\n\nBut that will of course do that for all commit-messages, so your point\nis still valid.\n\n  nikolai\n"},{"id":"21741","messageId":"7virn4gapp.fsf@assigned-by-dhcp.cox.net","threadId":"4484","inReplyTo":"448DB201.5090208@shlrm.org","subject":"Re: Thoughts on adding another hook to git","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-13T18:41:06Z","receivedAt":"2006-06-13T18:41:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Kowis <dkowis@shlrm.org> writes:\n\n> I'd like to be able to modify the commit message before it ends up in\n> the $EDITOR. This is a fairly trivial thing to implement:\n> Call ${GIT_DIR}/hooks/pre-editor on COMMIT_MESSAGE before opening it in\n> $EDITOR.\n\nThree random thoughts.\n\n - pre-editor is too generic a name because before making a\n   commit is not the only place we give you $EDITOR (both am and\n   tag do EDITOR thing IIRC).  So the hook name must be more\n   specific to the commit codepath (otherwise your pre-editor\n   hook needs to be able to tell which codepath called it).\n\n - git-commit gives you EDITOR when you are making a merge, and\n   you would probably want to keep the default merge commit\n   message without the prefixed directory thing.  You probably\n   do not want to do this while doing --amend either.\n\n - it might make sense to have a \"commit template\" that is used\n   when making a non-merge commit afresh (i.e. without -F, -m,\n   -c or -C to specify messages), instead of a hook script.\n"}]}