git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] git-help: add "web_or_man" and "web_or_info" config vars.
@ 2007-12-12  5:33 Christian Couder
  2007-12-12  5:35 ` Junio C Hamano
  2007-12-12 11:22 ` Johannes Schindelin
  0 siblings, 2 replies; 4+ messages in thread
From: Christian Couder @ 2007-12-12  5:33 UTC (permalink / raw)
  To: Junio Hamano; +Cc: git

These configuration variables can be used when you want to
use a web browser if DISPLAY is set and "man" or "info"
otherwise.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 Documentation/git-help.txt |   15 +++++++++++----
 help.c                     |   10 ++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt
index af5e5cb..c790584 100644
--- a/Documentation/git-help.txt
+++ b/Documentation/git-help.txt
@@ -24,10 +24,17 @@ up. The 'man' program is used by default for this purpose, but this
 can be overriden by other options.
 
 If no command line option is passed, the 'help.format' configuration
-variable will be checked. Supported values for this variable are
-"man", "info" and "web" (or "html" as a synonym to the latter). This
-makes git-help behave as if a command line option with the same long
-name as been passed to it.
+variable will be checked. The following values are supported for this
+variable; they make 'git-help' behave as their corresponding command
+line option:
+
+* "man" corresponds to '-m|--man',
+* "info" corresponds to '-i|--info',
+* "web" or "html" correspond to '-w|--web',
+* "web_or_man" corresponds to '-w|--web' if DISPLAY is set, '-m|--man'
+otherwise,
+* "web_or_info" corresponds to '-w|--web' if DISPLAY is set, '-i|--info'
+otherwise.
 
 Note that 'git --help ...' is identical as 'git help ...' because the
 former is internally converted into the latter.
diff --git a/help.c b/help.c
index af0a433..d46bc08 100644
--- a/help.c
+++ b/help.c
@@ -34,6 +34,16 @@ static void parse_help_format(const char *format)
 		help_format = web_format;
 		return;
 	}
+	if (!strcmp(format, "web_or_man")) {
+		char *display = getenv("DISPLAY");
+		help_format = display ? web_format : man_format;
+		return;
+	}
+	if (!strcmp(format, "web_or_info")) {
+		char *display = getenv("DISPLAY");
+		help_format = display ? web_format : info_format;
+		return;
+	}
 	die("unrecognized help format '%s'", format);
 }
 
-- 
1.5.3.7.2269.g4ae7

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] git-help: add "web_or_man" and "web_or_info" config vars.
  2007-12-12  5:33 [PATCH 2/2] git-help: add "web_or_man" and "web_or_info" config vars Christian Couder
@ 2007-12-12  5:35 ` Junio C Hamano
  2007-12-12  7:17   ` Christian Couder
  2007-12-12 11:22 ` Johannes Schindelin
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2007-12-12  5:35 UTC (permalink / raw)
  To: Christian Couder; +Cc: git

I personally feel this is going a bit overboard.  We'd be better off
doing something like this:

 - add 'help.external' configuration variable, that allows the user to
   set any external program;

 - spawn the external program when "git help <cmd>" is given, with <cmd>
   as the parameter;

 - add an option to 'git config' to dump various paths configured in the
   git program, such as manual page path, info page path and such, so
   that the external program can learn where things are.

The second point above means that translating "cat-file" to
"git-cat-file.html" becomes the responsibility for the external
program.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] git-help: add "web_or_man" and "web_or_info" config vars.
  2007-12-12  5:35 ` Junio C Hamano
@ 2007-12-12  7:17   ` Christian Couder
  0 siblings, 0 replies; 4+ messages in thread
From: Christian Couder @ 2007-12-12  7:17 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Le mercredi 12 décembre 2007, Junio C Hamano a écrit :
> I personally feel this is going a bit overboard. 

The main problem without it is for people who like web browser, but often 
use ssh without -Y. In this latter case, they may enter into "manly" mode, 
you know, and don't want to be bothered to install or use some kind of text 
based web browser.

Christian.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] git-help: add "web_or_man" and "web_or_info" config vars.
  2007-12-12  5:33 [PATCH 2/2] git-help: add "web_or_man" and "web_or_info" config vars Christian Couder
  2007-12-12  5:35 ` Junio C Hamano
@ 2007-12-12 11:22 ` Johannes Schindelin
  1 sibling, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2007-12-12 11:22 UTC (permalink / raw)
  To: Christian Couder; +Cc: Junio Hamano, git

Hi,

"web_or_man" is completely out of line with our existing CamelCase config 
variables.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-12-12 11:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-12  5:33 [PATCH 2/2] git-help: add "web_or_man" and "web_or_info" config vars Christian Couder
2007-12-12  5:35 ` Junio C Hamano
2007-12-12  7:17   ` Christian Couder
2007-12-12 11:22 ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).