help: use HTML as the default help format on Windows

When 'git help $cmd' is run without a format option (e.g. -w), the 'man' format is always used. On some platforms, however, manual page viewers are not often available. Introduce DEFAULT_HELP_FORMAT make variable in order to allow the default format configurable at compile time, and set it to HTML when compiling on Windows (but not Cygwin). Helped-by: Jeff King <peff@peff.net> Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Vincent van Ravesteijn committed Jun 6, 2012 at 20:28 UTC 1cc8af044cad37b5f7df85b177f6aa979aa3215a
2 files changed +16 -1
Makefile
+9
@@ -296,6 +296,10 @@ all::
296 # the diff algorithm. It gives a nice speedup if your processor has
297 # fast unaligned word loads. Does NOT work on big-endian systems!
298 # Enabled by default on x86_64.
299 +#
300 +# Define DEFAULT_HELP_FORMAT to "man", "info" or "html"
301 +# (defaults to "man") if you want to have a different default when
302 +# "git help" is called without a parameter specifying the format.
303
304 GIT-VERSION-FILE: FORCE
305 @$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1236,6 +1240,7 @@ ifeq ($(uname_S),Windows)
1240 BLK_SHA1 = YesPlease
1241 NO_POSIX_GOODIES = UnfortunatelyYes
1242 NATIVE_CRLF = YesPlease
1243 + DEFAULT_HELP_FORMAT = html
1244
1245 CC = compat/vcbuild/scripts/clink.pl
1246 AR = compat/vcbuild/scripts/lib.pl
@@ -1915,6 +1920,10 @@ SHELL_PATH_CQ_SQ = $(subst ','\'',$(SHELL_PATH_CQ))
1920 BASIC_CFLAGS += -DSHELL_PATH='$(SHELL_PATH_CQ_SQ)'
1921 endif
1922
1923 +ifdef DEFAULT_HELP_FORMAT
1924 +BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"'
1925 +endif
1926 +
1927 ALL_CFLAGS += $(BASIC_CFLAGS)
1928 ALL_LDFLAGS += $(BASIC_LDFLAGS)
1929
builtin/help.c
+7 -1
@@ -12,6 +12,10 @@
12 #include "column.h"
13 #include "help.h"
14
15 +#ifndef DEFAULT_HELP_FORMAT
16 +#define DEFAULT_HELP_FORMAT "man"
17 +#endif
18 +
19 static struct man_viewer_list {
20 struct man_viewer_list *next;
21 char name[FLEX_ARRAY];
@@ -445,7 +449,9 @@ int cmd_help(int argc, const char **argv, const char *prefix)
449 setup_git_directory_gently(&nongit);
450 git_config(git_help_config, NULL);
451
448 - if (parsed_help_format != HELP_FORMAT_NONE)
452 + if (parsed_help_format == HELP_FORMAT_NONE)
453 + help_format = parse_help_format(DEFAULT_HELP_FORMAT);
454 + else
455 help_format = parsed_help_format;
456
457 alias = alias_lookup(argv[0]);