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

[PATCH 00/24] Let 'git <command> -h' show usage without a git dir

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 9, 2009, 15:02 UTC
Message-ID
<20091109150235.GA23871@progeny.tock>
In-Reply-To
<20091108110341.GA23737@progeny.tock>
Junio C Hamano wrote:
> So I think the right approach is something like how you handled http-push;
> namely, check if the sole argument is "-h", and if so show help and exit.

I took a more aggressive approach with some commands. As long as it was obviously safe and not too complicated to implement, I let -h work wherever other options work.

Tested with
git_home=$(pwd)
while read a b
do
	cmd=${a#git-}
	test "$cmd" = "$a" && continue
	echo "$cmd"
	( cd /tmp && "$git_home/git" "$cmd" -h 2>&1 | head -1 )
done |
less
and the test suite.
Thoughts?
Jonathan Nieder (24):
  Retire fetch--tool helper to contrib/examples
  Show usage string for 'git grep -h'
  Show usage string for 'git cherry -h'
  Show usage string for 'git commit-tree -h'
  Show usage string for 'git merge-ours -h'
  Show usage string for 'git show-ref -h'
  check-ref-format: update usage string
  Show usage string for 'git check-ref-format -h'
  Show usage string for 'git fast-import -h'
  Show usage string for 'git get-tar-commit-id -h'
  Show usage string for 'git imap-send -h'
  Show usage string for 'git mailsplit -h'
  Show usage string for 'git merge-one-file -h'
  Show usage string for 'git rev-parse -h'
  Show usage string for 'git show-index -h'
  Show usage string for 'git unpack-file -h'
  Show usage string for 'git stripspace -h'
  merge: do not setup worktree twice
  Let 'git http-fetch -h' show usage outside any git repository
  http-fetch: add missing initialization of argv0_path
  Let 'git <command> -h' show usage without a git dir
  Let usage() take a printf-style format
  merge-{recursive,subtree}: use usage() to print usage
  diff --no-index: make the usage string less scary
 Documentation/git-show-ref.txt                     |    3 +-
 Makefile                                           |    1 -
 builtin-check-ref-format.c                         |    9 +++++++-
 builtin-commit-tree.c                              |    2 +-
 builtin-grep.c                                     |    7 ++++++
 builtin-log.c                                      |    9 ++++++++
 builtin-mailsplit.c                                |    2 +
 builtin-merge-ours.c                               |    6 +++++
 builtin-merge-recursive.c                          |    2 +-
 builtin-merge.c                                    |    1 -
 builtin-mv.c                                       |    8 +++---
 builtin-read-tree.c                                |    4 +-
 builtin-reflog.c                                   |    3 ++
 builtin-rerere.c                                   |    3 ++
 builtin-rev-parse.c                                |   10 +++++++++
 builtin-show-ref.c                                 |   10 +++++++-
 builtin-stripspace.c                               |    4 ++-
 builtin-tar-tree.c                                 |    6 +++++
 builtin.h                                          |    1 -
 .../examples/builtin-fetch--tool.c                 |    0
 diff-no-index.c                                    |    2 +-
 fast-import.c                                      |    3 ++
 git-compat-util.h                                  |    2 +-
 git-merge-one-file.sh                              |   12 ++++++++++
 git.c                                              |   22 ++++++++++---------
 http-fetch.c                                       |   21 ++++++++++++------
 imap-send.c                                        |    5 ++++
 index-pack.c                                       |    3 ++
 pack-redundant.c                                   |    3 ++
 show-index.c                                       |    5 ++++
 unpack-file.c                                      |    2 +-
 usage.c                                            |   14 ++++++++----
 32 files changed, 143 insertions(+), 42 deletions(-)
 rename builtin-fetch--tool.c => contrib/examples/builtin-fetch--tool.c (100%)
Previous: Jonathan NiederNext: Jonathan Nieder
Message 8 of 39 in “Let 'git <command> -h' show usage without a git dir”
  1. Let 'git <command> -h' show usage without a git dirJonathan Nieder, Nov 8, 2009
  2. Show usage string for 'git http-push -h'Jonathan Nieder, Nov 8, 2009
  3. Tay Ray ChuanNov 9, 2009
  4. Show usage string for 'git http-push -h'Jonathan Nieder, Nov 9, 2009
  5. Tay Ray ChuanNov 9, 2009
  6. Junio C HamanoNov 8, 2009
  7. Jonathan NiederNov 8, 2009
  8. 00/24 Let 'git <command> -h' show usage without a git dirJonathan Nieder, Nov 9, 2009
  9. 01/24 Retire fetch--tool helper to contrib/examplesJonathan Nieder, Nov 9, 2009
  10. 02/24 Show usage string for 'git grep -h'Jonathan Nieder, Nov 9, 2009
  11. 03/24 Show usage string for 'git cherry -h'Jonathan Nieder, Nov 9, 2009
  12. 04/24 Show usage string for 'git commit-tree -h'Jonathan Nieder, Nov 9, 2009
  13. 05/24 Show usage string for 'git merge-ours -h'Jonathan Nieder, Nov 9, 2009
  14. 06/24 Show usage string for 'git show-ref -h'Jonathan Nieder, Nov 9, 2009
  15. 07/24 check-ref-format: update usage stringJonathan Nieder, Nov 9, 2009
  16. Junio C HamanoNov 10, 2009
  17. 08/24 Show usage string for 'git check-ref-format -h'Jonathan Nieder, Nov 9, 2009
  18. 09/24 Show usage string for 'git fast-import -h'Jonathan Nieder, Nov 9, 2009
  19. 10/24 Show usage string for 'git get-tar-commit-id -h'Jonathan Nieder, Nov 9, 2009
  20. 11/24 Show usage string for 'git imap-send -h'Jonathan Nieder, Nov 9, 2009
  21. 12/24 Show usage string for 'git mailsplit -h'Jonathan Nieder, Nov 9, 2009
  22. 13/24 Show usage string for 'git merge-one-file -h'Jonathan Nieder, Nov 9, 2009
  23. 14/24 Show usage string for 'git rev-parse -h'Jonathan Nieder, Nov 9, 2009
  24. 15/24 Show usage string for 'git show-index -h'Jonathan Nieder, Nov 9, 2009
  25. 16/24 Show usage string for 'git unpack-file -h'Jonathan Nieder, Nov 9, 2009
  26. 17/24 Show usage string for 'git stripspace -h'Jonathan Nieder, Nov 9, 2009
  27. 18/24 merge: do not setup worktree twiceJonathan Nieder, Nov 9, 2009
  28. Junio C HamanoNov 10, 2009
  29. Jonathan NiederNov 11, 2009
  30. 19/24 Let 'git http-fetch -h' show usage outside any git repositoryJonathan Nieder, Nov 9, 2009
  31. 20/24 http-fetch: add missing initialization of argv0_pathJonathan Nieder, Nov 9, 2009
  32. Junio C HamanoNov 10, 2009
  33. Johannes SixtNov 10, 2009
  34. Jonathan NiederNov 11, 2009
  35. 21/24 Let 'git <command> -h' show usage without a git dirJonathan Nieder, Nov 9, 2009
  36. 22/24 Let usage() take a printf-style formatJonathan Nieder, Nov 9, 2009
  37. Junio C HamanoNov 10, 2009
  38. 23/24 merge-{recursive,subtree}: use usage() to print usageJonathan Nieder, Nov 9, 2009
  39. 24/24 diff --no-index: make the usage string less scaryJonathan Nieder, Nov 9, 2009

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.