{"thread":{"id":"52983","subject":"[Feature request] \"Hooks\" for git log","startedAt":"2020-03-12T15:06:50Z","lastAt":"2020-03-12T19:31:41Z","messageCount":6,"participants":["Konstantin Tokarev","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"393129","messageId":"558831584024173@sas1-438a02fc058e.qloud-c.yandex.net","threadId":"52983","inReplyTo":null,"subject":"[Feature request] \"Hooks\" for git log","fromName":"Konstantin Tokarev","fromEmail":"annulen@yandex.ru","sentAt":"2020-03-12T15:06:44Z","receivedAt":"2020-03-12T15:06:50Z","isPatch":false,"sender":{"key":"annulen@yandex.ru","avatar":null},"body":"Hello,\n\nWhile it's possible to filter commits in `git log` by their contents with\n--grep and -S options, it's not always possible for formulate desirable\nfilter in their terms.\n\nI think it would be very useful if git log provided new option named e.g.\n--hook or --script, which would take script path as an argument.\ngit log would follow it's normal way of operation, applying other filtering\noptions it was given, however intstead of printing info on commit that\nmatches filters, it invokes script with commit hash as an argument.\nScript can do whatever it needs with hash, including any git operations,\ncan print commit info to log if needed, or print something else, or keep\nsilence. If script returns non-zero, parent git log command terminates,\notherwise it continues.\n\n-- \nRegards,\nKonstantin\n\n\n"},{"id":"393133","messageId":"628991584029077@iva6-9bda19f40fc4.qloud-c.yandex.net","threadId":"52983","inReplyTo":"558831584024173@sas1-438a02fc058e.qloud-c.yandex.net","subject":"Re: [Feature request] \"Hooks\" for git log","fromName":"Konstantin Tokarev","fromEmail":"annulen@yandex.ru","sentAt":"2020-03-12T16:21:49Z","receivedAt":"2020-03-12T16:21:55Z","isPatch":false,"sender":{"key":"annulen@yandex.ru","avatar":null},"body":"\n\n12.03.2020, 18:06, \"Konstantin Tokarev\" <annulen@yandex.ru>:\n> Hello,\n>\n> While it's possible to filter commits in `git log` by their contents with\n> --grep and -S options, it's not always possible for formulate desirable\n> filter in their terms.\n>\n> I think it would be very useful if git log provided new option named e.g.\n> --hook or --script, which would take script path as an argument.\n> git log would follow it's normal way of operation, applying other filtering\n> options it was given, however intstead of printing info on commit that\n> matches filters, it invokes script with commit hash as an argument.\n> Script can do whatever it needs with hash, including any git operations,\n> can print commit info to log if needed, or print something else, or keep\n> silence. If script returns non-zero, parent git log command terminates,\n> otherwise it continues.\n\nOn the second thought, its user interface should probably be more like\n`git submodule foreach` to allow use of one-liners. For example, there is a\nbug which I've recently reported that prevents use of \n\ngit log --follow --full-diff <path>\n\nIt could have been worked around easily as\n\ngit log --follow <path> foreach git show $1\n\n(syntax may be different)\n\n-- \nRegards,\nKonstantin\n\n"},{"id":"393158","messageId":"xmqqo8t1flin.fsf@gitster.c.googlers.com","threadId":"52983","inReplyTo":"558831584024173@sas1-438a02fc058e.qloud-c.yandex.net","subject":"Re: [Feature request] \"Hooks\" for git log","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-03-12T18:58:24Z","receivedAt":"2020-03-12T18:58:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Konstantin Tokarev <annulen@yandex.ru> writes:\n\n> I think it would be very useful if git log provided new option named e.g.\n> --hook or --script, which would take script path as an argument.\n> git log would follow it's normal way of operation, applying other filtering\n> options it was given, however intstead of printing info on commit that\n> matches filters, it invokes script with commit hash as an argument.\n> Script can do whatever it needs with hash, including any git operations,\n> can print commit info to log if needed, or print something else, or keep\n> silence. If script returns non-zero, parent git log command terminates,\n> otherwise it continues.\n\nYou do not need a hook for that, no?\n\n $ git log --format='%H' ...your other options here... |\n   while read commit\n   do\n\t... your \"hook\" that checks the $commit to see if\n        ... it is \"interesting\" and shows or discard or whatever\n        ... it does comes here\n   done\n\n"},{"id":"393160","messageId":"79741584039971@myt6-4d759d962265.qloud-c.yandex.net","threadId":"52983","inReplyTo":"xmqqo8t1flin.fsf@gitster.c.googlers.com","subject":"Re: [Feature request] \"Hooks\" for git log","fromName":"Konstantin Tokarev","fromEmail":"annulen@yandex.ru","sentAt":"2020-03-12T19:08:20Z","receivedAt":"2020-03-12T19:08:25Z","isPatch":false,"sender":{"key":"annulen@yandex.ru","avatar":null},"body":"\n\n12.03.2020, 21:58, \"Junio C Hamano\" <gitster@pobox.com>:\n> Konstantin Tokarev <annulen@yandex.ru> writes:\n>\n>>  I think it would be very useful if git log provided new option named e.g.\n>>  --hook or --script, which would take script path as an argument.\n>>  git log would follow it's normal way of operation, applying other filtering\n>>  options it was given, however intstead of printing info on commit that\n>>  matches filters, it invokes script with commit hash as an argument.\n>>  Script can do whatever it needs with hash, including any git operations,\n>>  can print commit info to log if needed, or print something else, or keep\n>>  silence. If script returns non-zero, parent git log command terminates,\n>>  otherwise it continues.\n>\n> You do not need a hook for that, no?\n>\n>  $ git log --format='%H' ...your other options here... |\n>    while read commit\n>    do\n>         ... your \"hook\" that checks the $commit to see if\n>         ... it is \"interesting\" and shows or discard or whatever\n>         ... it does comes here\n>    done\n\nWhen pager is in use, git log loads commits lazily when you scroll down.\nI find this feature rather crucial for working with any long history, and\nI don't see how to achieve this with pipe.\n\n\n-- \nRegards,\nKonstantin\n\n"},{"id":"393163","messageId":"87951584041001@myt5-5e0e3f348369.qloud-c.yandex.net","threadId":"52983","inReplyTo":"79741584039971@myt6-4d759d962265.qloud-c.yandex.net","subject":"Re: [Feature request] \"Hooks\" for git log","fromName":"Konstantin Tokarev","fromEmail":"annulen@yandex.ru","sentAt":"2020-03-12T19:24:22Z","receivedAt":"2020-03-12T19:24:28Z","isPatch":false,"sender":{"key":"annulen@yandex.ru","avatar":null},"body":"\n\n12.03.2020, 22:08, \"Konstantin Tokarev\" <annulen@yandex.ru>:\n> 12.03.2020, 21:58, \"Junio C Hamano\" <gitster@pobox.com>:\n>>  Konstantin Tokarev <annulen@yandex.ru> writes:\n>>\n>>>   I think it would be very useful if git log provided new option named e.g.\n>>>   --hook or --script, which would take script path as an argument.\n>>>   git log would follow it's normal way of operation, applying other filtering\n>>>   options it was given, however intstead of printing info on commit that\n>>>   matches filters, it invokes script with commit hash as an argument.\n>>>   Script can do whatever it needs with hash, including any git operations,\n>>>   can print commit info to log if needed, or print something else, or keep\n>>>   silence. If script returns non-zero, parent git log command terminates,\n>>>   otherwise it continues.\n>>\n>>  You do not need a hook for that, no?\n>>\n>>   $ git log --format='%H' ...your other options here... |\n>>     while read commit\n>>     do\n>>          ... your \"hook\" that checks the $commit to see if\n>>          ... it is \"interesting\" and shows or discard or whatever\n>>          ... it does comes here\n>>     done\n>\n> When pager is in use, git log loads commits lazily when you scroll down.\n> I find this feature rather crucial for working with any long history, and\n> I don't see how to achieve this with pipe.\n\nNvm, passing to less -R makes it pause when needed. I've never realized it\nwas that simple.\n\n-- \nRegards,\nKonstantin\n\n"},{"id":"393165","messageId":"xmqqblp1fjzb.fsf@gitster.c.googlers.com","threadId":"52983","inReplyTo":"87951584041001@myt5-5e0e3f348369.qloud-c.yandex.net","subject":"Re: [Feature request] \"Hooks\" for git log","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-03-12T19:31:36Z","receivedAt":"2020-03-12T19:31:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Konstantin Tokarev <annulen@yandex.ru> writes:\n\n>> When pager is in use, git log loads commits lazily when you scroll down.\n>> I find this feature rather crucial for working with any long history, and\n>> I don't see how to achieve this with pipe.\n>\n> Nvm, passing to less -R makes it pause when needed. I've never realized it\n> was that simple.\n\nHeh, after all once you realize \"git log\" internally pipes its\noutput to the pager, doing the same thing yourself should become\ntrivial ;-)\n"}]}