path: root/Documentation/git-rev-parse.txt
diff options
authorJunio C Hamano <>2007-11-18 05:39:37 (GMT)
committerJunio C Hamano <>2007-11-18 05:39:37 (GMT)
commit9f4c4eb0e16d1e21eaaf5cab5591c3491456cd14 (patch)
tree8d5ce2c1b19e1c077e8fee1e93af2f6506a6e491 /Documentation/git-rev-parse.txt
parent9716f21b483233536d1eca9498f4ae4433dfd34f (diff)
parent9e384b4589cfba8fa057e0e124cdd4f6cc92fc66 (diff)
Merge branch 'ph/parseopt-sh'
* ph/parseopt-sh: fix --patches handling git-am: -i does not take a string parameter. sh-setup: don't let eval output to be shell-expanded. git-sh-setup: fix parseopt `eval` string underquoting Give git-am back the ability to add Signed-off-by lines. git-rev-parse --parseopt scripts: Add placeholders for OPTIONS_SPEC Migrate to use git-rev-parse --parseopt Migrate to use git-rev-parse --parseopt Migrate to use git-rev-parse --parseopt --keep-dashdash Migrate to use git-rev-parse --parseopt Migrate to use git-rev-parse --parseopt Migrate to use git-rev-parse --parseopt Migrate git-clone to use git-rev-parse --parseopt Migrate to use git-rev-parse --parseopt. Update git-sh-setup(1) to allow transparent use of git-rev-parse --parseopt Add a parseopt mode to git-rev-parse to bring parse-options to shell scripts.
Diffstat (limited to 'Documentation/git-rev-parse.txt')
1 files changed, 74 insertions, 2 deletions
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 4758c33..329fce0 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -23,6 +23,13 @@ distinguish between them.
+ Use `git-rev-parse` in option parsing mode (see PARSEOPT section below).
+ Only meaningful in `--parseopt` mode. Tells the option parser to echo
+ out the first `--` met instead of skipping it.
Do not output flags and parameters not meant for
`git-rev-list` command.
@@ -288,10 +295,75 @@ Here are a handful examples:
C^@ I J F
F^! D G H D F
+In `--parseopt` mode, `git-rev-parse` helps massaging options to bring to shell
+scripts the same facilities C builtins have. It works as an option normalizer
+(e.g. splits single switches aggregate values), a bit like `getopt(1)` does.
+It takes on the standard input the specification of the options to parse and
+understand, and echoes on the standard output a line suitable for `sh(1)` `eval`
+to replace the arguments with normalized ones. In case of error, it outputs
+usage on the standard error stream, and exits with code 129.
+Input Format
+`git-rev-parse --parseopt` input format is fully text based. It has two parts,
+separated by a line that contains only `--`. The lines before the separator
+(should be more than one) are used for the usage.
+The lines after the separator describe the options.
+Each line of options has this format:
+<opt_spec><arg_spec>? SP+ help LF
+ its format is the short option character, then the long option name
+ separated by a comma. Both parts are not required, though at least one
+ is necessary. `h,help`, `dry-run` and `f` are all three correct
+ `<opt_spec>`.
+ an `<arg_spec>` tells the option parser if the option has an argument
+ (`=`), an optional one (`?` though its use is discouraged) or none
+ (no `<arg_spec>` in that case).
+The remainder of the line, after stripping the spaces, is used
+as the help associated to the option.
+Blank lines are ignored, and lines that don't match this specification are used
+as option group headers (start the line with a space to create such
+lines on purpose).
+some-command [options] <args>...
+some-command does foo and bar!
+h,help show the help
+foo some nifty option --foo
+bar= some cool option --bar with an argument
+ An option group Header
+C? option C with an optional argument"
+eval `echo "$OPTS_SPEC" | git-rev-parse --parseopt -- "$@" || echo exit $?`
-Written by Linus Torvalds <> and
-Junio C Hamano <>
+Written by Linus Torvalds <> .
+Junio C Hamano <> and Pierre Habouzit <>