{"thread":{"id":"2539","subject":"[PATCH 3/3] git --help COMMAND brings up the git-COMMAND man-page.","startedAt":"2005-11-15T23:31:25Z","lastAt":"2005-11-16T00:24:06Z","messageCount":3,"participants":["Andreas Ericsson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"11953","messageId":"20051115233125.2C0355BF73@nox.op5.se","threadId":"2539","inReplyTo":null,"subject":"[PATCH 3/3] git --help COMMAND brings up the git-COMMAND man-page.","fromName":"Andreas Ericsson","fromEmail":"exon@op5.se","sentAt":"2005-11-15T23:31:25Z","receivedAt":"2005-11-15T23:31:25Z","isPatch":true,"sender":{"key":"exon@op5.se","avatar":"https://gravatar.com/avatar/b948c4f759e868f8e721e545e37afe2cf89cfa8e2ee8b70a432f0d76aee39891?d=mp&s=160"},"body":"\nIt's by design a bit stupid (matching ^git rather than ^git-), so as\nto work with 'gitk' and 'git' as well.\n\nSigned-off-by: Andreas Ericsson <ae@op5.se>\n\n---\n\n Documentation/git.txt |    2 ++\n git.c                 |   28 ++++++++++++++++++++++++++--\n 2 files changed, 28 insertions(+), 2 deletions(-)\n\napplies-to: 8a47ae8a825ab0e68ac46392bccd1ec16df39456\n3b7d6e6722b0d27ef5f9ae99a76d3ff909d3e98a\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 91e9f9f..7cbfaf8 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -24,6 +24,8 @@ OPTIONS\n \n --help::\n \tprints the synopsis and a list of available commands.\n+\tIf a git command is named this option will bring up the\n+\tman-page for that command.\n \n --exec-path::\n \tpath to wherever your core git programs are installed.\ndiff --git a/git.c b/git.c\nindex d189801..583923d 100644\n--- a/git.c\n+++ b/git.c\n@@ -160,6 +160,26 @@ static void prepend_to_path(const char *\n \tsetenv(\"PATH\", path, 1);\n }\n \n+/* has anyone seen 'man' installed anywhere else than in /usr/bin? */\n+#define PATH_TO_MAN \"/usr/bin/man\"\n+static void show_man_page(char *git_cmd)\n+{\n+\tchar *page;\n+\n+\tif (!strncmp(git_cmd, \"git\", 3))\n+\t\tpage = git_cmd;\n+\telse {\n+\t\tint page_len = strlen(git_cmd) + 4;\n+\n+\t\tpage = malloc(page_len + 1);\n+\t\tstrcpy(page, \"git-\");\n+\t\tstrcpy(page + 4, git_cmd);\n+\t\tpage[page_len] = 0;\n+\t}\n+\n+\texeclp(PATH_TO_MAN, \"man\", page, NULL);\n+}\n+\n int main(int argc, char **argv, char **envp)\n {\n \tchar git_command[PATH_MAX + 1];\n@@ -199,8 +219,12 @@ int main(int argc, char **argv, char **e\n \t\t\tusage(NULL, NULL);\n \t}\n \n-\tif (i >= argc || show_help)\n-\t\tusage(exec_path, NULL);\n+\tif (i >= argc || show_help) {\n+\t\tif (i >= argc)\n+\t\t\tusage(exec_path, NULL);\n+\n+\t\tshow_man_page(argv[i]);\n+\t}\n \n \t/* allow relative paths, but run with exact */\n \tif (chdir(exec_path)) {\n---\n0.99.9.GIT\n"},{"id":"11963","messageId":"7vsltxeakh.fsf@assigned-by-dhcp.cox.net","threadId":"2539","inReplyTo":"20051115233125.2C0355BF73@nox.op5.se","subject":"Re: [PATCH 3/3] git --help COMMAND brings up the git-COMMAND man-page.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-15T23:49:18Z","receivedAt":"2005-11-15T23:49:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"exon@op5.se (Andreas Ericsson) writes:\n\n> It's by design a bit stupid (matching ^git rather than ^git-), so as\n> to work with 'gitk' and 'git' as well.\n>\n> Signed-off-by: Andreas Ericsson <ae@op5.se>\n\nThanks, stupid is fine.\n\n> +/* has anyone seen 'man' installed anywhere else than in /usr/bin? */\n> +#define PATH_TO_MAN \"/usr/bin/man\"\n> +static void show_man_page(char *git_cmd)\n> +{\n> +\tchar *page;\n> +\n> +\tif (!strncmp(git_cmd, \"git\", 3))\n> +\t\tpage = git_cmd;\n> +\telse {\n> +\t\tint page_len = strlen(git_cmd) + 4;\n> +\n> +\t\tpage = malloc(page_len + 1);\n> +\t\tstrcpy(page, \"git-\");\n> +\t\tstrcpy(page + 4, git_cmd);\n> +\t\tpage[page_len] = 0;\n> +\t}\n> +\n> +\texeclp(PATH_TO_MAN, \"man\", page, NULL);\n> +}\n\nIf you do PATH_TO_MAN absolute, execl would suffice, but just\nsaying \"man\" and have execlp look for it would be easier to\nmanage.\n"},{"id":"11970","messageId":"437A7C26.5020400@op5.se","threadId":"2539","inReplyTo":"7vsltxeakh.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 3/3] git --help COMMAND brings up the git-COMMAND man-page.","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2005-11-16T00:24:06Z","receivedAt":"2005-11-16T00:24:06Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n>>+\n>>+\texeclp(PATH_TO_MAN, \"man\", page, NULL);\n>>+}\n> \n> \n> If you do PATH_TO_MAN absolute, execl would suffice, but just\n> saying \"man\" and have execlp look for it would be easier to\n> manage.\n> \n> \n\nNever even occurred to me, actually. I just re-submitted the patch.\n\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"}]}