{"thread":{"id":"12679","subject":"[PATCH 1/2] web--browse: use custom commands defined at config time","startedAt":"2008-03-14T04:56:49Z","lastAt":"2008-03-19T01:00:01Z","messageCount":4,"participants":["Christian Couder","Xavier Maillard"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"72031","messageId":"20080314055649.0bd59b47.chriscool@tuxfamily.org","threadId":"12679","inReplyTo":null,"subject":"[PATCH 1/2] web--browse: use custom commands defined at config time","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2008-03-14T04:56:49Z","receivedAt":"2008-03-14T04:56:49Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This a steal from 964473a0429f625d019c69ab55644540174acf85 by\nCharles Bailey.\n\nCurrently \"git web--browse\" is restricted to a set of commands defined\nin the script. You can subvert the \"browser.<tool>.path\" to force \"git\nweb--browse\" to use a different command, but if you have a command\nwhose invocation syntax does not match one of the current tools then\nyou would have to write a wrapper script for it.\n\nThis patch adds a git config variable \"browser.<tool>.cmd\" which\nallows a more flexible browser choice.\n\nIf you run \"git web--browse\" with -t/--tool, -b/--browser or the\n\"web.browser\" config variable set to an unrecognized tool then \"git\nweb--browse\" will query the \"browser.<tool>.cmd\" config variable. If\nthis variable exists, then \"git web--browse\" will treat the specified\ntool as a custom command and will use a shell eval to run the command\nwith the URLs added as extra parameters.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-web--browse.sh |   15 +++++++++++++--\n 1 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/git-web--browse.sh b/git-web--browse.sh\nindex 1023b90..384148a 100755\n--- a/git-web--browse.sh\n+++ b/git-web--browse.sh\n@@ -23,12 +23,18 @@ USAGE='[--browser=browser|--tool=browser] [--config=conf.var] url/file ...'\n NONGIT_OK=Yes\n . git-sh-setup\n \n+valid_custom_tool()\n+{\n+\tbrowser_cmd=\"$(git config \"browser.$1.cmd\")\"\n+\ttest -n \"$browser_cmd\"\n+}\n+\n valid_tool() {\n \tcase \"$1\" in\n \t\tfirefox | iceweasel | konqueror | w3m | links | lynx | dillo | open)\n \t\t\t;; # happy\n \t\t*)\n-\t\t\treturn 1\n+\t\t\tvalid_custom_tool \"$1\" || return 1\n \t\t\t;;\n \tesac\n }\n@@ -122,7 +128,7 @@ else\n \n     init_browser_path \"$browser\"\n \n-    if ! type \"$browser_path\" > /dev/null 2>&1; then\n+    if test -z \"$browser_cmd\" && ! type \"$browser_path\" > /dev/null 2>&1; then\n \tdie \"The browser $browser is not available as '$browser_path'.\"\n     fi\n fi\n@@ -157,4 +163,9 @@ case \"$browser\" in\n     dillo)\n \t\"$browser_path\" \"$@\" &\n \t;;\n+    *)\n+\tif test -n \"$browser_cmd\"; then\n+\t    ( eval $browser_cmd \"$@\" )\n+\tfi\n+\t;;\n esac\n-- \n1.5.4.4.598.gcdb00b\n"},{"id":"72182","messageId":"200803151300.m2FD0XWh003243@localhost.localdomain","threadId":"12679","inReplyTo":"20080314055649.0bd59b47.chriscool@tuxfamily.org","subject":"Re: [PATCH 1/2] web--browse: use custom commands defined at config time","fromName":"Xavier Maillard","fromEmail":"xma@gnu.org","sentAt":"2008-03-15T13:00:33Z","receivedAt":"2008-03-15T13:00:33Z","isPatch":true,"sender":{"key":"xma@gnu.org","avatar":null},"body":"\n   This patch adds a git config variable \"browser.<tool>.cmd\" which\n   allows a more flexible browser choice.\n\nWell done ! Now we need it in help.c too :)\n\n   Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n\nTested-by: Xavier Maillard <xma@gnu.org>\n\n   ---\n    git-web--browse.sh |   15 +++++++++++++--\n    1 files changed, 13 insertions(+), 2 deletions(-)\n\nPlease update the header file as well (copyright header, it is\nyear 2008 here :)).\n\n\tXavier\n-- \nhttp://www.gnu.org\nhttp://www.april.org\nhttp://www.lolica.org\n"},{"id":"72343","messageId":"200803180556.51930.chriscool@tuxfamily.org","threadId":"12679","inReplyTo":"200803151300.m2FD0XWh003243@localhost.localdomain","subject":"Re: [PATCH 1/2] web--browse: use custom commands defined at config time","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2008-03-18T04:56:51Z","receivedAt":"2008-03-18T04:56:51Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Le samedi 15 mars 2008, Xavier Maillard a écrit :\n>    This patch adds a git config variable \"browser.<tool>.cmd\" which\n>    allows a more flexible browser choice.\n>\n> Well done ! Now we need it in help.c too :)\n\nI started by \"man.<tool>.path\" (patches should follow soon), and I will work \non \"man.<tool>.cmd\" really soon now.\n\n>    Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n>\n> Tested-by: Xavier Maillard <xma@gnu.org>\n\nThanks again for your tests. They are very much appreciated.\n\n> Please update the header file as well (copyright header, it is\n> year 2008 here :)).\n\nIs it so important ? Some files like \"help.c\" don't even have copyright \nnotice. Isn't it ok as long as they come with the license file (COPYING) ?\n\nThanks,\nChristian.\n"},{"id":"72371","messageId":"200803190100.m2J101bU031978@localhost.localdomain","threadId":"12679","inReplyTo":"200803180556.51930.chriscool@tuxfamily.org","subject":"Re: [PATCH 1/2] web--browse: use custom commands defined at config time","fromName":"Xavier Maillard","fromEmail":"xma@gnu.org","sentAt":"2008-03-19T01:00:01Z","receivedAt":"2008-03-19T01:00:01Z","isPatch":true,"sender":{"key":"xma@gnu.org","avatar":null},"body":"\n   > Please update the header file as well (copyright header, it is\n   > year 2008 here :)).\n\n   Is it so important ? Some files like \"help.c\" don't even have copyright \n   notice. Isn't it ok as long as they come with the license file (COPYING) ?\n\nDunno if it is \"important\" for the Git project, it is a habit :)\nBy the way, is there any policy on that topic ?\n\n\tXavier\n-- \nhttp://www.gnu.org\nhttp://www.april.org\nhttp://www.lolica.org\n"}]}