{"thread":{"id":"11085","subject":"[PATCH 1/3] git-help: add -i|--info option to display info page.","startedAt":"2007-12-02T05:07:40Z","lastAt":"2007-12-04T05:54:17Z","messageCount":6,"participants":["Christian Couder","Junio C Hamano","Pascal Obry"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"61617","messageId":"20071202060740.269e54ad.chriscool@tuxfamily.org","threadId":"11085","inReplyTo":null,"subject":"[PATCH 1/3] git-help: add -i|--info option to display info page.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-12-02T05:07:40Z","receivedAt":"2007-12-02T05:07:40Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"\"git help --info XXX\" will now call \"info git-XXX\".\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n help.c |   35 +++++++++++++++++++++++++++--------\n 1 files changed, 27 insertions(+), 8 deletions(-)\n\ndiff --git a/help.c b/help.c\nindex 37a9c25..0f1cb71 100644\n--- a/help.c\n+++ b/help.c\n@@ -239,24 +239,32 @@ void list_common_cmds_help(void)\n \t}\n }\n \n-static void show_man_page(const char *git_cmd)\n+static const char *cmd_to_page(const char *git_cmd)\n {\n-\tconst char *page;\n-\n \tif (!prefixcmp(git_cmd, \"git\"))\n-\t\tpage = git_cmd;\n+\t\treturn git_cmd;\n \telse {\n \t\tint page_len = strlen(git_cmd) + 4;\n \t\tchar *p = xmalloc(page_len + 1);\n \t\tstrcpy(p, \"git-\");\n \t\tstrcpy(p + 4, git_cmd);\n \t\tp[page_len] = 0;\n-\t\tpage = p;\n+\t\treturn p;\n \t}\n+}\n \n+static void show_man_page(const char *git_cmd)\n+{\n+\tconst char *page = cmd_to_page(git_cmd);\n \texeclp(\"man\", \"man\", page, NULL);\n }\n \n+static void show_info_page(const char *git_cmd)\n+{\n+\tconst char *page = cmd_to_page(git_cmd);\n+\texeclp(\"info\", \"info\", page, NULL);\n+}\n+\n void help_unknown_cmd(const char *cmd)\n {\n \tfprintf(stderr, \"git: '%s' is not a git-command. See 'git --help'.\\n\", cmd);\n@@ -269,10 +277,8 @@ int cmd_version(int argc, const char **argv, const char *prefix)\n \treturn 0;\n }\n \n-int cmd_help(int argc, const char **argv, const char *prefix)\n+static void check_help_cmd(const char *help_cmd)\n {\n-\tconst char *help_cmd = argc > 1 ? argv[1] : NULL;\n-\n \tif (!help_cmd) {\n \t\tprintf(\"usage: %s\\n\\n\", git_usage_string);\n \t\tlist_common_cmds_help();\n@@ -284,6 +290,19 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \t\tlist_commands();\n \t\texit(0);\n \t}\n+}\n+\n+int cmd_help(int argc, const char **argv, const char *prefix)\n+{\n+\tconst char *help_cmd = argc > 1 ? argv[1] : NULL;\n+\tcheck_help_cmd(help_cmd);\n+\n+\tif (!strcmp(help_cmd, \"--info\") || !strcmp(help_cmd, \"-i\")) {\n+\t\thelp_cmd = argc > 2 ? argv[2] : NULL;\n+\t\tcheck_help_cmd(help_cmd);\n+\n+\t\tshow_info_page(help_cmd);\n+\t}\n \n \telse\n \t\tshow_man_page(help_cmd);\n-- \n1.5.3.6.1993.g154f-dirty\n"},{"id":"61674","messageId":"475272CF.40602@obry.net","threadId":"11085","inReplyTo":"20071202060740.269e54ad.chriscool@tuxfamily.org","subject":"Re: [PATCH 1/3] git-help: add -i|--info option to display info page.","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2007-12-02T08:54:39Z","receivedAt":"2007-12-02T08:54:39Z","isPatch":true,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"Christian Couder a écrit :\n> \"git help --info XXX\" will now call \"info git-XXX\".\n\nIf would be nice if this could be more generic. For example I'd like to\nuse Emacs woman mode instead of info. Can't we have something like\n\n   $ git help --ext XXX\n\n\"ext\" standing for external and calling whatever command recorded into\n.gitconfig for example ?\n\nPascal.\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|              http://www.obry.net\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595\n"},{"id":"61632","messageId":"7vodd9zbvt.fsf@gitster.siamese.dyndns.org","threadId":"11085","inReplyTo":"475272CF.40602@obry.net","subject":"Re: [PATCH 1/3] git-help: add -i|--info option to display info page.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-02T09:25:42Z","receivedAt":"2007-12-02T09:25:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pascal Obry <pascal@obry.net> writes:\n\n> Christian Couder a écrit :\n>> \"git help --info XXX\" will now call \"info git-XXX\".\n>\n> If would be nice if this could be more generic. For example I'd like to\n> use Emacs woman mode instead of info. Can't we have something like\n>\n>    $ git help --ext XXX\n>\n> \"ext\" standing for external and calling whatever command recorded into\n> .gitconfig for example ?\n\nThere is a bit of conflict here.  We could do that and make the\nimplementation of \"ext\" command responsible to transform \"commit\" in\n\n\t$ git help --ext commit\n\nto the location of manual page (or formatted HTML page, or node in the\ninfo documentation).  git itself does not need to know much about where\nthe help material is in such an implementation.\n\nBut Christian's series is about making such \"ext\" thing easier to write.\nNo matter what kind of web browser is used, it needs to be told where\nthe preformatted HTML page for git-commit command is (and it does not\ncare where git-commit.1 manpage is found or what the node is called in\ngit.info document).  It makes it a bit too limiting by defining -w (web)\nand -i (info) upfront without offering -x (ext), but we need to start\nsomewhere.\n\nHaving said that, I think this is a post 1.5.4 material.  Please keep\nthe discussion going, so that we can have something people can agree on\nearly after 1.5.4.\n"},{"id":"61730","messageId":"200712030653.15694.chriscool@tuxfamily.org","threadId":"11085","inReplyTo":"7vodd9zbvt.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/3] git-help: add -i|--info option to display info page.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-12-03T05:53:14Z","receivedAt":"2007-12-03T05:53:14Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Le dimanche 2 décembre 2007, Junio C Hamano a écrit :\n> Pascal Obry <pascal@obry.net> writes:\n> >\n> > If would be nice if this could be more generic. For example I'd like to\n> > use Emacs woman mode instead of info. Can't we have something like\n> >\n> >    $ git help --ext XXX\n> >\n> > \"ext\" standing for external and calling whatever command recorded into\n> > .gitconfig for example ?\n>\n> There is a bit of conflict here.  We could do that and make the\n> implementation of \"ext\" command responsible to transform \"commit\" in\n>\n> \t$ git help --ext commit\n>\n> to the location of manual page (or formatted HTML page, or node in the\n> info documentation).  git itself does not need to know much about where\n> the help material is in such an implementation.\n>\n> But Christian's series is about making such \"ext\" thing easier to write.\n> No matter what kind of web browser is used, it needs to be told where\n> the preformatted HTML page for git-commit command is (and it does not\n> care where git-commit.1 manpage is found or what the node is called in\n> git.info document).  It makes it a bit too limiting by defining -w (web)\n> and -i (info) upfront without offering -x (ext), but we need to start\n> somewhere.\n\nYeah, I think that the user should be able to choose both the format and the \ntool used for help pages. And that we should start to make more popular \nformats and tools work well first. That means HTML with web browser first.\n(And yeah, my first patch is about \"info\", but it was a very low hanging \nfruit.)\n\nIn the end we may want to support many other tools and format. For example:\n\n\"git help --format=man --tool=konqueror log\" or\n\"git help -m --tool=konqueror log\"\n\nwould launch something like: \"konqueror 'man:git-log(1)'\"\n\nBut of course, to be able to do that, we have to know how each tool is \nworking, because the syntax has a good chance to be different in each case.\n\nIf we provide a -x|--ext upfront and we don't check if we know about the \ntool the user wants to use, then we will not get information about how to \nproperly use the tool and we may break without any meaningfull error for \nmany of them.\n\nSo if someone has information about how \"woman\" or other web or man or info \nbrowser can be used, I will be glad to collect it and eventually use it to \ntry to make \"git help\" work for the tool (though I don't promise to test \nthem on platform other than Linux), but I will focus on web formats and \ntools first. Patches are welcome too. \n\nThanks in advance,\nChristian.\n"},{"id":"61809","messageId":"47544EE5.1050707@obry.net","threadId":"11085","inReplyTo":"200712030653.15694.chriscool@tuxfamily.org","subject":"Re: [PATCH 1/3] git-help: add -i|--info option to display info page.","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2007-12-03T18:45:57Z","receivedAt":"2007-12-03T18:45:57Z","isPatch":true,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"Christian Couder a écrit :\n> So if someone has information about how \"woman\" or other web or man or info \n\nOk about woman. Woman is an Emacs mode to display man pages. To send man\npage to display in Emacs from the command line one can use emacsclient\nfor example. I'm already doing this for standard man pages with a bash\nfunction. This function does something like this:\n\n   $ emacsclient -e '(woman \"git\")'\n\n-e is for eval and the argument is the Emacs Lisp string to evaluate.\n\nLet me know if you need more information about woman.\n\nI think it would be nice to be able to define a Git alias. In the string\nsome %x could be replaced by the man page requested. We could define\nmultiple replacements:\n\n   %n  -  the man entry (git-commit)\n   %s  -  the simple name of the man page (git-commit.1)\n   %f  -  the full pathname of the man page (/usr/man/man1/git-commit.1)\n   %i  -  the full pathname of the info page\n\nWith this I think it should be possible to define and configure any\nexternal tool to display the man page.\n\nThis would be more versatile and could be used to display info or man\nusing whatever tool.\n\nPascal.\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|              http://www.obry.net\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595\n"},{"id":"61868","messageId":"200712040654.18322.chriscool@tuxfamily.org","threadId":"11085","inReplyTo":"47544EE5.1050707@obry.net","subject":"Re: [PATCH 1/3] git-help: add -i|--info option to display info page.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-12-04T05:54:17Z","receivedAt":"2007-12-04T05:54:17Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Le lundi 3 décembre 2007, Pascal Obry a écrit :\n> Ok about woman. Woman is an Emacs mode to display man pages. To send man\n> page to display in Emacs from the command line one can use emacsclient\n> for example. I'm already doing this for standard man pages with a bash\n> function. This function does something like this:\n>\n>    $ emacsclient -e '(woman \"git\")'\n>\n> -e is for eval and the argument is the Emacs Lisp string to evaluate.\n>\n> Let me know if you need more information about woman.\n\nThanks Pascal, I will indeed tell you if I have questions about woman.\n(Given the name, I wouldn't be surprised if it's hard to deal with.)\n\nChristian.\n"}]}