[PATCH 1/4] help: make 'git-help--browse' usable outside 'git-help'.

Previous thread: [ANNOUNCE] GIT 1.5.4 by Junio C Hamano on Saturday, February 2, 2008 - 12:34 am. (48 messages)

Next thread: [PATCH 2/4] help--browse: add '--config' option to check a config option for a browser. by Christian Couder on Saturday, February 2, 2008 - 2:32 am. (1 message)
To: Junio Hamano <junkio@...>, Eric Wong <normalperson@...>
Cc: <git@...>
Date: Saturday, February 2, 2008 - 2:32 am

By moving some help specific stuff from 'git-help--browse.sh'
into 'help.c', we make it possible to use 'git-help--browse'
outside 'git-help'.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
Makefile | 2 +-
git-help--browse.sh | 24 +++++++++---------------
help.c | 18 +++++++++++++++++-
3 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/Makefile b/Makefile
index 92341c4..a03fd2e 100644
--- a/Makefile
+++ b/Makefile
@@ -819,6 +819,7 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)

help.o: help.c common-cmds.h GIT-CFLAGS
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
+ '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
'-DGIT_INFO_PATH="$(infodir_SQ)"' $<

@@ -839,7 +840,6 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
-e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
- -e 's|@@HTMLDIR@@|$(htmldir_SQ)|g' \
$@.sh >$@+ && \
chmod +x $@+ && \
mv $@+ $@
diff --git a/git-help--browse.sh b/git-help--browse.sh
index 10b0a36..8189c08 100755
--- a/git-help--browse.sh
+++ b/git-help--browse.sh
@@ -16,18 +16,13 @@
# git maintainer.
#

-USAGE='[--browser=browser|--tool=browser] [cmd to display] ...'
+USAGE='[--browser=browser|--tool=browser] url/file ...'

# This must be capable of running outside of git directory, so
# the vanilla git-sh-setup should not be used.
NONGIT_OK=Yes
. git-sh-setup

-# Install data.
-html_dir="@@HTMLDIR@@"
-
-test -f "$html_dir/git.html" || die "No documentation directory found."
-
valid_tool() {
case "$1" in
firefox | iceweasel | konqueror | w3m | links | lynx | dillo)
@@ -71,6 +66,8 @@ do
shift
done

+test $# = 0 && usage
+
if test -z "$browser"
then
for opt in "help.browser" "web.browser"
@@ -113,16 +110,13 @@ else
fi
fi

-pages=$(for p in "$@"; do echo "$html_dir/$p.html" ; done)
...

To: Christian Couder <chriscool@...>
Cc: <git@...>, Eric Wong <normalperson@...>
Date: Saturday, February 2, 2008 - 3:30 am

I was initially puzzled why Eric was CC'ed while reading this
first patch in the 4-patch series. It would have been nicer to
start the series by mentioning the ultimate goal of the series
upfront. You are not making it usable just by anybody, but have
a specific goal of sharing the mechanism to launch user's web

When the helper was run without specifying any page, it used to
show the toplevel "git" documentation. If your eventual goal is
to allow general browsing, obviously you do not want such a
logic here, and it needs to migrate to the caller. So far, it

Gets a "page", makes page_path by concatenating the manual page

So this function used to give whatever "page" it got back from
cmd_to_page(). Maybe it could have been NULL but that would
have been handled by the browser helper just fine.

A reviewer would be left wondering if this means that you lost

And this part makes the reviewer even more worried. If page
could be NULL, then get_html_page_path() would be fed a NULL
pointer, which is given to strbuf_addf()! Ugh.

Then the reviewer would find out that cmd_to_page() would never
return NULL, as it has its own NULL-to-"git" fallback logic.

I think the code is good, but the proposed commit log message
has some room for improvements.

Something like...

[PATCH 1/4] help: make 'git-help--browse' usable outside 'git-help'

"git-help--browse" helper is to launch a browser of the
user's choice to view the HTML version of git documentation
for a given command. It used to take the name of a command,
convert it to the path of the documentation by prefixing the
directory name and appending the ".html" suffix, and start
the browser on the path.

This updates the division of labor between the caller in
help.c and git-help--browser helper. The helper is now
responsible for launching a browser of the user's choice
on given URLs, and it is the caller's responsibility to
tell it the paths to documentation files.

...

To: Junio C Hamano <gitster@...>
Cc: <git@...>, Eric Wong <normalperson@...>
Date: Sunday, February 3, 2008 - 1:00 am

Yeah, I could have explained some parts of the patch more.

Great commit message indeed! Though I fear that such long messages (for a
not very long patch) could take precious screen real estate when using "git
log" or otherwise bother some other readers.

Anyway do you want me to resend the patch or the series with improved commit

You definitely deserve it. Thanks for your great release and maintainer

Thanks,
Christian.
-

Previous thread: [ANNOUNCE] GIT 1.5.4 by Junio C Hamano on Saturday, February 2, 2008 - 12:34 am. (48 messages)

Next thread: [PATCH 2/4] help--browse: add '--config' option to check a config option for a browser. by Christian Couder on Saturday, February 2, 2008 - 2:32 am. (1 message)