path: root/Documentation/git-rev-parse.txt
diff options
authorChristian Couder <>2009-04-25 04:55:26 (GMT)
committerJunio C Hamano <>2009-05-10 07:30:28 (GMT)
commit503253771e93fd9f29c9f0773223d456677452c4 (patch)
tree4f27fb569cc8589a9f6c78e8af12837f931dc432 /Documentation/git-rev-parse.txt
parent38ef7507d1dce87d68f177a6209d716339fee854 (diff)
rev-parse: add --sq-quote to shell quote arguments
Signed-off-by: Christian Couder <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'Documentation/git-rev-parse.txt')
1 files changed, 34 insertions, 1 deletions
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 52c353e..4bbdd05 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -30,6 +30,11 @@ OPTIONS
Only meaningful in `--parseopt` mode. Tells the option parser to echo
out the first `--` met instead of skipping it.
+ Use 'git-rev-parse' in shell quoting mode (see SQ-QUOTE
+ section below). In contrast to the `--sq` option below, this
+ mode does only quoting. Nothing else is done to command input.
Do not output flags and parameters not meant for
'git-rev-list' command.
@@ -64,7 +69,8 @@ OPTIONS
properly quoted for consumption by shell. Useful when
you expect your parameter to contain whitespaces and
newlines (e.g. when using pickaxe `-S` with
- 'git-diff-\*').
+ 'git-diff-\*'). In contrast to the `--sq-quote` option,
+ the command input is still interpreted as usual.
When showing object names, prefix them with '{caret}' and
@@ -406,6 +412,33 @@ C? option C with an optional argument"
eval `echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?`
+In `--sq-quote` mode, 'git-rev-parse' echoes on the standard output a
+single line suitable for `sh(1)` `eval`. This line is made by
+normalizing the arguments following `--sq-quote`. Nothing other than
+quoting the arguments is done.
+If you want command input to still be interpreted as usual by
+'git-rev-parse' before the output is shell quoted, see the `--sq`
+$ cat > <<\EOF
+args=$(git rev-parse --sq-quote "$@") # quote user-supplied arguments
+command="git frotz -n24 $args" # and use it inside a handcrafted
+ # command line
+eval "$command"
+$ sh "a b'c"