git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Junio Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH 2/2] git-help: add "web_or_man" and "web_or_info" config vars.
Date: Wed, 12 Dec 2007 06:33:25 +0100	[thread overview]
Message-ID: <20071212063325.92cd29a8.chriscool@tuxfamily.org> (raw)

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

             reply	other threads:[~2007-12-12  5:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-12  5:33 Christian Couder [this message]
2007-12-12  5:35 ` [PATCH 2/2] git-help: add "web_or_man" and "web_or_info" config vars Junio C Hamano
2007-12-12  7:17   ` Christian Couder
2007-12-12 11:22 ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071212063325.92cd29a8.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).