Re: [PATCH 3/3] git --help COMMAND brings up the git-COMMAND man-page.

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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.

Re: [PATCH 3/3] git --help COMMAND brings up the git-COMMAND man-page.

From: Andreas Ericsson <hidden>
Date: 2016-06-15 22:42:12

Junio C Hamano wrote:
quoted
+
+	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.
Never even occurred to me, actually. I just re-submitted the patch.


-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help