help--browse: add '--config' option to check a config option for a browser.
The value of this new command line option will be used as a key to check the configuration for an help browser. This should remove the last bit in 'git-help--browse' that was specific to 'git-help', so that other git command can use 'git-help--browse'. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Feb 2, 2008 at 07:32 UTC
caa87713bca77c441c09282aa5b18b179bcfa90d
2 files changed
+19
-6
git-help--browse.sh
+18
-5
@@ -16,7 +16,7 @@
16
# git maintainer.
17
#
18
19
-USAGE='[--browser=browser|--tool=browser] url/file ...'
19
+USAGE='[--browser=browser|--tool=browser] [--config=conf.var] url/file ...'
20
21
# This must be capable of running outside of git directory, so
22
# the vanilla git-sh-setup should not be used.
@@ -53,6 +53,18 @@ do
53
shift ;;
54
esac
55
;;
56
+ -c|--config*)
57
+ case "$#,$1" in
58
+ *,*=*)
59
+ conf=`expr "z$1" : 'z-[^=]*=\(.*\)'`
60
+ ;;
61
+ 1,*)
62
+ usage ;;
63
+ *)
64
+ conf="$2"
65
+ shift ;;
66
+ esac
67
+ ;;
68
--)
69
break
70
;;
@@ -70,15 +82,16 @@ test $# = 0 && usage
82
83
if test -z "$browser"
84
then
73
- for opt in "help.browser" "web.browser"
85
+ for opt in "$conf" "web.browser"
86
do
87
+ test -z "$opt" && continue
88
browser="`git config $opt`"
89
test -z "$browser" || break
90
done
91
if test -n "$browser" && ! valid_tool "$browser"; then
79
- echo >&2 "git config option $opt set to unknown browser: $browser"
80
- echo >&2 "Resetting to default..."
81
- unset browser
92
+ echo >&2 "git config option $opt set to unknown browser: $browser"
93
+ echo >&2 "Resetting to default..."
94
+ unset browser
95
fi
96
fi
97
help.c
+1
-1
@@ -347,7 +347,7 @@ static void show_html_page(const char *git_cmd)
347
348
get_html_page_path(&page_path, page);
349
350
- execl_git_cmd("help--browse", page_path.buf, NULL);
350
+ execl_git_cmd("help--browse", "-c", "help.browser", page_path.buf, NULL);
351
}
352
353
void help_unknown_cmd(const char *cmd)