git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv2] Add the possibility to specify a default help format

From
Vincent van Ravesteijn <vfr@lyx.org>
Date
Jun 6, 2012, 20:28 UTC
Message-ID
<1339014496-6736-1-git-send-email-vfr@lyx.org>
In-Reply-To
<1338987397-7376-1-git-send-email-vfr@lyx.org>

At the moment, the default help format (i.e. the format that is chosen if 'git help xxx' is called without a help format parameter) is defined by the switch to be 'man'. However, on different platforms the preferred format might differ. For example, on Windows there is no man viewer, so we would prefer html.

This patch adds the possibility to choose a default help format on compilation by defining DEFAULT_HELP_FORMAT. If it is not specified the default is still 'man'.

Example:
  make DEFAULT_HELP_FORMAT=info
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org>
---
 Makefile       |    9 +++++++++
 builtin/help.c |    8 +++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index 4592f1f..9df6213 100644
--- a/Makefile
+++ b/Makefile
@@ -296,6 +296,10 @@ all::
 # the diff algorithm.  It gives a nice speedup if your processor has
 # fast unaligned word loads.  Does NOT work on big-endian systems!
 # Enabled by default on x86_64.
+#
+# Define DEFAULT_HELP_FORMAT to "man", "info" or "html" 
+# (defaults to "man") if you want to have a different default when
+# "git help" is called without a parameter specifying the format.
 
 GIT-VERSION-FILE: FORCE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1236,6 +1240,7 @@ ifeq ($(uname_S),Windows)
 	BLK_SHA1 = YesPlease
 	NO_POSIX_GOODIES = UnfortunatelyYes
 	NATIVE_CRLF = YesPlease
+	DEFAULT_HELP_FORMAT = html
 
 	CC = compat/vcbuild/scripts/clink.pl
 	AR = compat/vcbuild/scripts/lib.pl
@@ -1915,6 +1920,10 @@ SHELL_PATH_CQ_SQ = $(subst ','\'',$(SHELL_PATH_CQ))
 BASIC_CFLAGS += -DSHELL_PATH='$(SHELL_PATH_CQ_SQ)'
 endif
 
+ifdef DEFAULT_HELP_FORMAT
+BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"'
+endif
+
 ALL_CFLAGS += $(BASIC_CFLAGS)
 ALL_LDFLAGS += $(BASIC_LDFLAGS)
 
diff --git a/builtin/help.c b/builtin/help.c
index 43d3c84..536d4fd 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -12,6 +12,10 @@
 #include "column.h"
 #include "help.h"
 
+#ifndef DEFAULT_HELP_FORMAT
+#define DEFAULT_HELP_FORMAT "man"
+#endif
+
 static struct man_viewer_list {
 	struct man_viewer_list *next;
 	char name[FLEX_ARRAY];
@@ -445,7 +449,9 @@ int cmd_help(int argc, const char **argv, const char *prefix)
 	setup_git_directory_gently(&nongit);
 	git_config(git_help_config, NULL);
 
-	if (parsed_help_format != HELP_FORMAT_NONE)
+	if (parsed_help_format == HELP_FORMAT_NONE)
+		help_format = parse_help_format(DEFAULT_HELP_FORMAT);
+	else
 		help_format = parsed_help_format;
 
 	alias = alias_lookup(argv[0]);
-- 
1.7.9.msysgit.0
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 8 in “Add the possibility to specify a default help format”
  1. Add the possibility to specify a default help formatVincent van Ravesteijn, Jun 6, 2012
  2. Jeff KingJun 6, 2012
  3. Add the DEFAULT_HELP_FORMAT option to Makefilevfr@lyx.org, Jun 6, 2012
  4. Junio C HamanoJun 6, 2012
  5. Vincent van RavesteijnJun 6, 2012
  6. Junio C HamanoJun 6, 2012
  7. [PATCHv2] Add the possibility to specify a default help formatVincent van Ravesteijn, Jun 6, 2012
  8. Junio C HamanoJun 6, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.