git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/3] help: introduce option --exclude-guides

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 26, 2016, 19:06 UTC
Message-ID
<xmqq8tvjgxiy.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160826175836.14073-3-ralf.thielow@gmail.com>
Ralf Thielow <ralf.thielow@gmail.com> writes:
> Introduce option --exclude-guides to the help command.  With this option
> being passed, "git help" will open man pages only for actual commands.

Let's hide this option from command help of "git help" itself, drop the short-and-sweet "-e", not command-line complete it, and leave it not-mentioned here.

It is a different story if this option would really help the end users, but I do not think that is the case. If this were to face the end users properly, we would need to worry about making sure that "git help -g -e" would error out, and getting all the other possible corner cases right. I do not think the amount of effort required to do so (even the "trying to enumerate what other possible corner cases there may be" part) is worth it.

Show 7 quoted lines
> In the test script we do two things I'd like to point out:
>
>> +       test_config help.htmlpath test://html &&
>
> As we pass a URL, Git won't check if the given path looks like
> a documentation directory.  Another solution would be to create
> a directory, add a file "git.html" to it and just use this path.

I think this is OK; with s|As we pass a URL|As we pass a string with :// in it|, the first sentence can be a in-code comment in the test that does this and will help readers of the code in the future.

>> +       test_config help.browser firefox
>
> Git checks if the browser is known, so the "test-browser" needs to
> pretend it is one of them.

Are you talking about the hardcoded list in valid_tool() helper function in git-web--browse.sh? If we use the established escape hatch implemented by valid_custom_tool() helper there by setting browser.*.cmd, would that be sufficient to work around the "Git checks if the browser is known"?

Show 11 quoted lines
> diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt
> index 40d328a..eeb1950 100644
> --- a/Documentation/git-help.txt
> +++ b/Documentation/git-help.txt
> @@ -8,7 +8,7 @@ git-help - Display help information about Git
>  SYNOPSIS
>  --------
>  [verse]
> -'git help' [-a|--all] [-g|--guide]
> +'git help' [-a|--all] [-e|--exclude-guides] [-g|--guide]
>  	   [-i|--info|-m|--man|-w|--web] [COMMAND|GUIDE]
So, let's not do this.
Show 12 quoted lines
> diff --git a/builtin/help.c b/builtin/help.c
> index e8f79d7..40901a9 100644
> --- a/builtin/help.c
> +++ b/builtin/help.c
> @@ -37,8 +37,10 @@ static int show_all = 0;
>  static int show_guides = 0;
>  static unsigned int colopts;
>  static enum help_format help_format = HELP_FORMAT_NONE;
> +static int exclude_guides;
>  static struct option builtin_help_options[] = {
>  	OPT_BOOL('a', "all", &show_all, N_("print all available commands")),
> +	OPT_BOOL('e', "exclude-guides", &exclude_guides, N_("exclude guides")),

So I'd suggest using PARSE_OPT_HIDDEN for this one and drop 'e' shorthand. The only caller of this mode does not use it.

Show 13 quoted lines
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index c1b2135..b148164 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1393,7 +1393,7 @@ _git_help ()
>  {
>  	case "$cur" in
>  	--*)
> -		__gitcomp "--all --guides --info --man --web"
> +		__gitcomp "--all --exclude-guides --guides --info --man --web"
>  		return
>  		;;
>  	esac
So, let's not do this.
Show 17 quoted lines
> diff --git a/t/t0012-help.sh b/t/t0012-help.sh
> new file mode 100755
> index 0000000..fb1abd7
> --- /dev/null
> +++ b/t/t0012-help.sh
> @@ -0,0 +1,33 @@
> +#!/bin/sh
> +
> +test_description='help'
> +
> +. ./test-lib.sh
> +
> +configure_help () {
> +	test_config help.format html &&
> +	test_config help.htmlpath test://html &&
> +	test_config help.browser firefox 
> +}
Would replacing the last line with:
	test_config browser.test.cmd ./test-browser &&
	test_config help.browser test

and then writing to test-browser work just as well? If so, that would be much cleaner and more preferrable.

Show 6 quoted lines
> +
> +test_expect_success "setup" "
> +	write_script firefox <<-\EOF
> +	exit 0
> +	EOF
> +"

Unless there is a good reason you MUST do so, avoid quoting the test body with double quotes, as it invites mistakes [*1*].

Also, how about using something like:
	write_script test-browser <<-\EOF
	i=0
	for arg
        do
		i=$(( $i + 1 ))
		echo "$i: $arg"
	done >test-browser.log
        EOF

instead? That way, you can ensure that "git help status" attempts to call git-status.html with the expected path, not gitstatus.html or status.html, or somesuch, immediately after running "git help status" in the next test by inspecting test-browser.log ...

> +test_expect_success "works for commands and guides by default" "
> +	configure_help &&
> +	git help status &&
... right here.

The output from the test-browser does not have to be multi-line; just doing

	echo "$*"
might be sufficient.
> +	git help revisions
> +"
Thanks.
[Footnote]
*1* Can you immediately tell why this test is broken?
test_expect_success "two commits do not have the same ID" "
	git commit --allow-empty -m first &&
	one=$(git rev-parse --verify HEAD) &&
	test_tick &&
	git commit --allow-empty -m second &&
	two=$(git rev-parse --verify HEAD) &&
	test $one != $two
"
Previous: Ralf ThielowNext: Junio C Hamano
Message 40 of 46 in “`git stash --help` tries to pull up nonexistent file gitstack.html”
  1. Joseph MusserAug 12, 2016
  2. Junio C HamanoAug 12, 2016
  3. Lars SchneiderAug 12, 2016
  4. Joseph MusserAug 12, 2016
  5. Junio C HamanoAug 12, 2016
  6. Jacob KellerAug 12, 2016
  7. help: make option --help open man pages only for Git commandsRalf Thielow, Aug 12, 2016
  8. Junio C HamanoAug 12, 2016
  9. Junio C HamanoAug 12, 2016
  10. Philip OakleyAug 13, 2016
  11. Junio C HamanoAug 13, 2016
  12. help: make option --help open man pages only for Git commandsRalf Thielow, Aug 15, 2016
  13. Philip OakleyAug 15, 2016
  14. Junio C HamanoAug 15, 2016
  15. Philip OakleyAug 15, 2016
  16. Junio C HamanoAug 15, 2016
  17. John KeepingAug 16, 2016
  18. help: make option --help open man pages only for Git commandsRalf Thielow, Aug 16, 2016
  19. John KeepingAug 16, 2016
  20. Ralf ThielowAug 16, 2016
  21. Junio C HamanoAug 16, 2016
  22. Ralf ThielowAug 16, 2016
  23. Junio C HamanoAug 16, 2016
  24. 0/2 help: make option --help open man pages only for Git commandsRalf Thielow, Aug 18, 2016
  25. 1/2 help: introduce option --command-onlyRalf Thielow, Aug 18, 2016
  26. Philip OakleyAug 18, 2016
  27. 2/2 help: make option --help open man pages only for Git commandsRalf Thielow, Aug 18, 2016
  28. Junio C HamanoAug 18, 2016
  29. Ralf ThielowAug 23, 2016
  30. Remi Galan AlfonsoAug 19, 2016
  31. Ralf ThielowAug 23, 2016
  32. Johannes SchindelinAug 19, 2016
  33. Junio C HamanoAug 19, 2016
  34. Ralf ThielowAug 23, 2016
  35. Johannes SchindelinAug 24, 2016
  36. 0/3 help: make option --help open man pages only for Git commandsRalf Thielow, Aug 26, 2016
  37. 1/3 Revert "display HTML in default browser using Windows' shell API"Ralf Thielow, Aug 26, 2016
  38. 3/3 help: make option --help open man pages only for Git commandsRalf Thielow, Aug 26, 2016
  39. 2/3 help: introduce option --exclude-guidesRalf Thielow, Aug 26, 2016
  40. Junio C HamanoAug 26, 2016
  41. Junio C HamanoAug 26, 2016
  42. Ralf ThielowAug 26, 2016
  43. Junio C HamanoAug 26, 2016
  44. Ralf ThielowAug 26, 2016
  45. Junio C HamanoAug 26, 2016
  46. Ralf ThielowAug 26, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.