Skip to content

Commit 1cc8af0

Browse files
vfr-nlgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Vincent van Ravesteijn <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent befc5ed commit 1cc8af0

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ all::
296296
# the diff algorithm. It gives a nice speedup if your processor has
297297
# fast unaligned word loads. Does NOT work on big-endian systems!
298298
# 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.
299303

300304
GIT-VERSION-FILE: FORCE
301305
@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1236,6 +1240,7 @@ ifeq ($(uname_S),Windows)
12361240
BLK_SHA1 = YesPlease
12371241
NO_POSIX_GOODIES = UnfortunatelyYes
12381242
NATIVE_CRLF = YesPlease
1243+
DEFAULT_HELP_FORMAT = html
12391244

12401245
CC = compat/vcbuild/scripts/clink.pl
12411246
AR = compat/vcbuild/scripts/lib.pl
@@ -1915,6 +1920,10 @@ SHELL_PATH_CQ_SQ = $(subst ','\'',$(SHELL_PATH_CQ))
19151920
BASIC_CFLAGS += -DSHELL_PATH='$(SHELL_PATH_CQ_SQ)'
19161921
endif
19171922

1923+
ifdef DEFAULT_HELP_FORMAT
1924+
BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"'
1925+
endif
1926+
19181927
ALL_CFLAGS += $(BASIC_CFLAGS)
19191928
ALL_LDFLAGS += $(BASIC_LDFLAGS)
19201929

builtin/help.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#include "column.h"
1313
#include "help.h"
1414

15+
#ifndef DEFAULT_HELP_FORMAT
16+
#define DEFAULT_HELP_FORMAT "man"
17+
#endif
18+
1519
static struct man_viewer_list {
1620
struct man_viewer_list *next;
1721
char name[FLEX_ARRAY];
@@ -445,7 +449,9 @@ int cmd_help(int argc, const char **argv, const char *prefix)
445449
setup_git_directory_gently(&nongit);
446450
git_config(git_help_config, NULL);
447451

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
449455
help_format = parsed_help_format;
450456

451457
alias = alias_lookup(argv[0]);

0 commit comments

Comments
 (0)