Skip to content

Commit

Permalink
help--browse: add '--config' option to check a config option for a br…
Browse files Browse the repository at this point in the history
…owser.

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>
  • Loading branch information
Christian Couder authored and Junio C Hamano committed Feb 5, 2008
1 parent 482cce8 commit caa8771
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions git-help--browse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# git maintainer.
#

USAGE='[--browser=browser|--tool=browser] url/file ...'
USAGE='[--browser=browser|--tool=browser] [--config=conf.var] url/file ...'

# This must be capable of running outside of git directory, so
# the vanilla git-sh-setup should not be used.
Expand Down Expand Up @@ -53,6 +53,18 @@ do
shift ;;
esac
;;
-c|--config*)
case "$#,$1" in
*,*=*)
conf=`expr "z$1" : 'z-[^=]*=\(.*\)'`
;;
1,*)
usage ;;
*)
conf="$2"
shift ;;
esac
;;
--)
break
;;
Expand All @@ -70,15 +82,16 @@ test $# = 0 && usage

if test -z "$browser"
then
for opt in "help.browser" "web.browser"
for opt in "$conf" "web.browser"
do
test -z "$opt" && continue
browser="`git config $opt`"
test -z "$browser" || break
done
if test -n "$browser" && ! valid_tool "$browser"; then
echo >&2 "git config option $opt set to unknown browser: $browser"
echo >&2 "Resetting to default..."
unset browser
echo >&2 "git config option $opt set to unknown browser: $browser"
echo >&2 "Resetting to default..."
unset browser
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion help.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static void show_html_page(const char *git_cmd)

get_html_page_path(&page_path, page);

execl_git_cmd("help--browse", page_path.buf, NULL);
execl_git_cmd("help--browse", "-c", "help.browser", page_path.buf, NULL);
}

void help_unknown_cmd(const char *cmd)
Expand Down

0 comments on commit caa8771

Please sign in to comment.