Re: [PATCH 3/3] git --help COMMAND brings up the git-COMMAND man-page.
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:12
exon@op5.se (Andreas Ericsson) writes:
It's by design a bit stupid (matching ^git rather than ^git-), so as to work with 'gitk' and 'git' as well. Signed-off-by: Andreas Ericsson <redacted>
Thanks, stupid is fine.
+/* has anyone seen 'man' installed anywhere else than in /usr/bin? */
+#define PATH_TO_MAN "/usr/bin/man"
+static void show_man_page(char *git_cmd)
+{
+ char *page;
+
+ if (!strncmp(git_cmd, "git", 3))
+ page = git_cmd;
+ else {
+ int page_len = strlen(git_cmd) + 4;
+
+ page = malloc(page_len + 1);
+ strcpy(page, "git-");
+ strcpy(page + 4, git_cmd);
+ page[page_len] = 0;
+ }
+
+ execlp(PATH_TO_MAN, "man", page, NULL);
+}If you do PATH_TO_MAN absolute, execl would suffice, but just saying "man" and have execlp look for it would be easier to manage.