Code

Merge branch 'master' into cc/help
authorJunio C Hamano <gitster@pobox.com>
Mon, 10 Dec 2007 09:22:42 +0000 (01:22 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Dec 2007 09:22:42 +0000 (01:22 -0800)
This is to primarily pull in MANPATH tweak and help.txt formatting fix
from the master branch.

1  2 
Documentation/Makefile
Documentation/git-help.txt
Documentation/git.txt
Makefile
help.c

Simple merge
Simple merge
Simple merge
diff --cc Makefile
index 932b0d4346dc7480e1ce56ed33614cf9bb50a546,4cdb84ba6242595a5e0e4765a16497aad53a56f3..429bc1ddb55f502b5c7ed51515aa7600599b2f15
+++ b/Makefile
@@@ -745,9 -747,9 +749,10 @@@ ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC
  
  DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  bindir_SQ = $(subst ','\'',$(bindir))
+ mandir_SQ = $(subst ','\'',$(mandir))
  gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
  template_dir_SQ = $(subst ','\'',$(template_dir))
 +htmldir_SQ = $(subst ','\'',$(htmldir))
  prefix_SQ = $(subst ','\'',$(prefix))
  
  SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
diff --cc help.c
index ec0d0155ac79051c3fcfbbbc72db1ea32404e069,f935887d34f2d766120a2628ee13e074b76a6c17..56477f4506a94905c58dad09543bfbb68db61d91
--- 1/help.c
--- 2/help.c
+++ b/help.c
@@@ -239,25 -239,43 +239,47 @@@ void list_common_cmds_help(void
        }
  }
  
 +static const char *cmd_to_page(const char *git_cmd)
 +{
 +      if (!git_cmd)
 +              return "git";
 +      else if (!prefixcmp(git_cmd, "git"))
 +              return git_cmd;
 +      else {
 +              int page_len = strlen(git_cmd) + 4;
 +              char *p = xmalloc(page_len + 1);
 +              strcpy(p, "git-");
 +              strcpy(p + 4, git_cmd);
 +              p[page_len] = 0;
 +              return p;
 +      }
 +}
 +
+ 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;
 -
 -      if (!prefixcmp(git_cmd, "git"))
 -              page = git_cmd;
 -      else {
 -              int page_len = strlen(git_cmd) + 4;
 -              char *p = xmalloc(page_len + 1);
 -              strcpy(p, "git-");
 -              strcpy(p + 4, git_cmd);
 -              p[page_len] = 0;
 -              page = p;
 -      }
 -
 +      const char *page = cmd_to_page(git_cmd);
+       setup_man_path();
        execlp("man", "man", page, NULL);
  }