summaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-12-10 09:22:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-12-10 09:22:42 (GMT)
commit7be2b6e02b4f2a1b4812764f65b12cafb11a934e (patch)
treec94ad7eb3a4d478a1c71eb6ef0aaf1c0f7348660 /help.c
parentc07a07c588fea82c2426d795a75324b3035c0a71 (diff)
parent591aa2536fdbc4090ba8d4ca512d4ee7df4bf05d (diff)
downloadgit-7be2b6e02b4f2a1b4812764f65b12cafb11a934e.zip
git-7be2b6e02b4f2a1b4812764f65b12cafb11a934e.tar.gz
git-7be2b6e02b4f2a1b4812764f65b12cafb11a934e.tar.bz2
Merge branch 'master' into cc/help
This is to primarily pull in MANPATH tweak and help.txt formatting fix from the master branch.
Diffstat (limited to 'help.c')
-rw-r--r--help.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/help.c b/help.c
index ec0d015..56477f4 100644
--- a/help.c
+++ b/help.c
@@ -255,9 +255,31 @@ static const char *cmd_to_page(const char *git_cmd)
}
}
+static void setup_man_path(void)
+{
+ struct strbuf new_path;
+ const char *old_path = getenv("MANPATH");
+
+ strbuf_init(&new_path, 0);
+
+ /* We should always put ':' after our path. If there is no
+ * old_path, the ':' at the end will let 'man' to try
+ * system-wide paths after ours to find the manual page. If
+ * there is old_path, we need ':' as delimiter. */
+ strbuf_addstr(&new_path, GIT_MAN_PATH);
+ strbuf_addch(&new_path, ':');
+ if (old_path)
+ strbuf_addstr(&new_path, old_path);
+
+ setenv("MANPATH", new_path.buf, 1);
+
+ strbuf_release(&new_path);
+}
+
static void show_man_page(const char *git_cmd)
{
const char *page = cmd_to_page(git_cmd);
+ setup_man_path();
execlp("man", "man", page, NULL);
}