1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
\r
4 <article lang="en" id="git-rev-parse(1)">
\r
6 <title>git-rev-parse(1)</title>
\r
8 <primary>git-rev-parse(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-rev-parse - Pick out and massage parameters</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
18 <literallayout><emphasis>git rev-parse</emphasis> [ --option ] <args>…</literallayout>
\r
21 <simplesect id="_description">
\r
22 <title>DESCRIPTION</title>
\r
23 <simpara>Many git porcelainish commands take mixture of flags
\r
24 (i.e. parameters that begin with a dash <emphasis>-</emphasis>) and parameters
\r
25 meant for the underlying <emphasis>git rev-list</emphasis> command they use internally
\r
26 and flags and parameters for the other commands they use
\r
27 downstream of <emphasis>git rev-list</emphasis>. This command is used to
\r
28 distinguish between them.</simpara>
\r
30 <simplesect id="_options">
\r
31 <title>OPTIONS</title>
\r
39 Use <emphasis>git rev-parse</emphasis> in option parsing mode (see PARSEOPT section below).
\r
49 Only meaningful in <emphasis>--parseopt</emphasis> mode. Tells the option parser to echo
\r
50 out the first <emphasis>--</emphasis> met instead of skipping it.
\r
56 --stop-at-non-option
\r
60 Only meaningful in <emphasis>--parseopt</emphasis> mode. Lets the option parser stop at
\r
61 the first non-option argument. This can be used to parse sub-commands
\r
62 that take options themselves.
\r
72 Use <emphasis>git rev-parse</emphasis> in shell quoting mode (see SQ-QUOTE
\r
73 section below). In contrast to the <emphasis>--sq</emphasis> option below, this
\r
74 mode does only quoting. Nothing else is done to command input.
\r
84 Do not output flags and parameters not meant for
\r
85 <emphasis>git rev-list</emphasis> command.
\r
95 Do not output flags and parameters meant for
\r
96 <emphasis>git rev-list</emphasis> command.
\r
106 Do not output non-flag parameters.
\r
116 Do not output flag parameters.
\r
122 --default <arg>
\r
126 If there is no parameter given by the user, use <emphasis><arg></emphasis>
\r
137 The parameter given must be usable as a single, valid
\r
138 object name. Otherwise barf and abort.
\r
151 Only meaningful in <emphasis>--verify</emphasis> mode. Do not output an error
\r
152 message if the first argument is not a valid object name;
\r
153 instead exit with non-zero status silently.
\r
163 Usually the output is made one line per flag and
\r
164 parameter. This option makes output a single line,
\r
165 properly quoted for consumption by shell. Useful when
\r
166 you expect your parameter to contain whitespaces and
\r
167 newlines (e.g. when using pickaxe <emphasis>-S</emphasis> with
\r
168 <emphasis>git diff-*</emphasis>). In contrast to the <emphasis>--sq-quote</emphasis> option,
\r
169 the command input is still interpreted as usual.
\r
179 When showing object names, prefix them with <emphasis>^</emphasis> and
\r
180 strip <emphasis>^</emphasis> prefix from the object names that already have
\r
191 Usually the object names are output in SHA1 form (with
\r
192 possible <emphasis>^</emphasis> prefix); this option makes them output in a
\r
193 form as close to the original input as possible.
\r
199 --symbolic-full-name
\r
203 This is similar to --symbolic, but it omits input that
\r
204 are not refs (i.e. branch or tag names; or more
\r
205 explicitly disambiguating "heads/master" form, when you
\r
206 want to name the "master" branch when there is an
\r
207 unfortunately named tag "master"), and show them as full
\r
208 refnames (e.g. "refs/heads/master").
\r
214 --abbrev-ref[=(strict|loose)]
\r
218 A non-ambiguous short name of the objects name.
\r
219 The option core.warnAmbiguousRefs is used to select the strict
\r
230 Show all refs found in <emphasis>refs/</emphasis>.
\r
236 --branches[=pattern]
\r
242 --remotes[=pattern]
\r
246 Show all branches, tags, or remote-tracking branches,
\r
247 respectively (i.e., refs found in <emphasis>refs/heads</emphasis>,
\r
248 <emphasis>refs/tags</emphasis>, or <emphasis>refs/remotes</emphasis>, respectively).
\r
250 <simpara>If a <emphasis>pattern</emphasis> is given, only refs matching the given shell glob are
\r
251 shown. If the pattern does not contain a globbing character (<emphasis>?</emphasis>,
\r
252 <emphasis>*</emphasis>, or <emphasis>[</emphasis>), it is turned into a prefix match by appending <emphasis>/*</emphasis>.</simpara>
\r
261 Show all refs matching the shell glob pattern <emphasis>pattern</emphasis>. If
\r
262 the pattern does not start with <emphasis>refs/</emphasis>, this is automatically
\r
263 prepended. If the pattern does not contain a globbing
\r
264 character (<emphasis>?</emphasis>, <emphasis>*</emphasis>, or <emphasis>[</emphasis>), it is turned into a prefix
\r
265 match by appending <emphasis>/*</emphasis>.
\r
275 Show the absolute path of the top-level directory.
\r
285 When the command is invoked from a subdirectory, show the
\r
286 path of the current directory relative to the top-level
\r
297 When the command is invoked from a subdirectory, show the
\r
298 path of the top-level directory relative to the current
\r
299 directory (typically a sequence of "../", or an empty string).
\r
309 Show <emphasis>$GIT_DIR</emphasis> if defined. Otherwise show the path to
\r
310 the .git directory, relative to the current directory.
\r
312 <simpara>If <emphasis>$GIT_DIR</emphasis> is not defined and the current directory
\r
313 is not detected to lie in a git repository or work tree
\r
314 print a message to stderr and exit with nonzero status.</simpara>
\r
319 --is-inside-git-dir
\r
323 When the current working directory is below the repository
\r
324 directory print "true", otherwise "false".
\r
330 --is-inside-work-tree
\r
334 When the current working directory is inside the work tree of the
\r
335 repository print "true", otherwise "false".
\r
341 --is-bare-repository
\r
345 When the repository is bare print "true", otherwise "false".
\r
355 List the GIT_* environment variables that are local to the
\r
356 repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR).
\r
357 Only the names of the variables are listed, not their value,
\r
358 even if they are set.
\r
371 Instead of outputting the full SHA1 values of object names try to
\r
372 abbreviate them to a shorter unique name. When no length is specified
\r
373 7 is used. The minimum length is 4.
\r
386 Parse the date string, and output the corresponding
\r
387 --max-age= parameter for <emphasis>git rev-list</emphasis>.
\r
396 --before=datestring
\r
400 Parse the date string, and output the corresponding
\r
401 --min-age= parameter for <emphasis>git rev-list</emphasis>.
\r
407 <args>…
\r
411 Flags and parameters to be parsed.
\r
417 --resolve-git-dir <path>
\r
421 Check if <path> is a valid git-dir or a git-file pointing to a valid
\r
422 git-dir. If <path> is a valid git-dir the resolved path to git-dir will
\r
429 <simplesect id="_specifying_revisions">
\r
430 <title>SPECIFYING REVISIONS</title>
\r
431 <simpara>A revision parameter <emphasis><rev></emphasis> typically, but not necessarily, names a
\r
432 commit object. It uses what is called an <emphasis>extended SHA1</emphasis>
\r
433 syntax. Here are various ways to spell object names. The
\r
434 ones listed near the end of this list name trees and
\r
435 blobs contained in a commit.</simpara>
\r
439 <emphasis><sha1></emphasis>, e.g. <emphasis>dae86e1950b1277e545cee180551750029cfe735</emphasis>, <emphasis>dae86e</emphasis>
\r
443 The full SHA1 object name (40-byte hexadecimal string), or
\r
444 a leading substring that is unique within the repository.
\r
445 E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both
\r
446 name the same commit object if there is no other object in
\r
447 your repository whose object name starts with dae86e.
\r
453 <emphasis><describeOutput></emphasis>, e.g. <emphasis>v1.7.4.2-679-g3bee7fb</emphasis>
\r
457 Output from <emphasis>git describe</emphasis>; i.e. a closest tag, optionally
\r
458 followed by a dash and a number of commits, followed by a dash, a
\r
459 <emphasis>g</emphasis>, and an abbreviated object name.
\r
465 <emphasis><refname></emphasis>, e.g. <emphasis>master</emphasis>, <emphasis>heads/master</emphasis>, <emphasis>refs/heads/master</emphasis>
\r
469 A symbolic ref name. E.g. <emphasis>master</emphasis> typically means the commit
\r
470 object referenced by <emphasis>refs/heads/master</emphasis>. If you
\r
471 happen to have both <emphasis>heads/master</emphasis> and <emphasis>tags/master</emphasis>, you can
\r
472 explicitly say <emphasis>heads/master</emphasis> to tell git which one you mean.
\r
473 When ambiguous, a <emphasis><name></emphasis> is disambiguated by taking the
\r
474 first match in the following rules:
\r
476 <orderedlist numeration="arabic">
\r
479 If <emphasis>$GIT_DIR/<name></emphasis> exists, that is what you mean (this is usually
\r
480 useful only for <emphasis>HEAD</emphasis>, <emphasis>FETCH_HEAD</emphasis>, <emphasis>ORIG_HEAD</emphasis>, <emphasis>MERGE_HEAD</emphasis>
\r
481 and <emphasis>CHERRY_PICK_HEAD</emphasis>);
\r
486 otherwise, <emphasis>refs/<name></emphasis> if it exists;
\r
491 otherwise, <emphasis>refs/tags/<refname></emphasis> if it exists;
\r
496 otherwise, <emphasis>refs/heads/<name></emphasis> if it exists;
\r
501 otherwise, <emphasis>refs/remotes/<name></emphasis> if it exists;
\r
506 otherwise, <emphasis>refs/remotes/<name>/HEAD</emphasis> if it exists.
\r
508 <simpara><emphasis>HEAD</emphasis> names the commit on which you based the changes in the working tree.
\r
509 <emphasis>FETCH_HEAD</emphasis> records the branch which you fetched from a remote repository
\r
510 with your last <emphasis>git fetch</emphasis> invocation.
\r
511 <emphasis>ORIG_HEAD</emphasis> is created by commands that move your <emphasis>HEAD</emphasis> in a drastic
\r
512 way, to record the position of the <emphasis>HEAD</emphasis> before their operation, so that
\r
513 you can easily change the tip of the branch back to the state before you ran
\r
515 <emphasis>MERGE_HEAD</emphasis> records the commit(s) which you are merging into your branch
\r
516 when you run <emphasis>git merge</emphasis>.
\r
517 <emphasis>CHERRY_PICK_HEAD</emphasis> records the commit which you are cherry-picking
\r
518 when you run <emphasis>git cherry-pick</emphasis>.</simpara>
\r
519 <simpara>Note that any of the <emphasis>refs/*</emphasis> cases above may come either from
\r
520 the <emphasis>$GIT_DIR/refs</emphasis> directory or from the <emphasis>$GIT_DIR/packed-refs</emphasis> file.</simpara>
\r
527 <emphasis><refname>@{<date>}</emphasis>, e.g. <emphasis>master@{yesterday}</emphasis>, <emphasis>HEAD@{5 minutes ago}</emphasis>
\r
531 A ref followed by the suffix <emphasis>@</emphasis> with a date specification
\r
532 enclosed in a brace
\r
533 pair (e.g. <emphasis>{yesterday}</emphasis>, <emphasis>{1 month 2 weeks 3 days 1 hour 1
\r
534 second ago}</emphasis> or <emphasis>{1979-02-26 18:30:00}</emphasis>) specifies the value
\r
535 of the ref at a prior point in time. This suffix may only be
\r
536 used immediately following a ref name and the ref must have an
\r
537 existing log (<emphasis>$GIT_DIR/logs/<ref></emphasis>). Note that this looks up the state
\r
538 of your <emphasis role="strong">local</emphasis> ref at a given time; e.g., what was in your local
\r
539 <emphasis>master</emphasis> branch last week. If you want to look at commits made during
\r
540 certain times, see <emphasis>--since</emphasis> and <emphasis>--until</emphasis>.
\r
546 <emphasis><refname>@{<n>}</emphasis>, e.g. <emphasis>master@{1}</emphasis>
\r
550 A ref followed by the suffix <emphasis>@</emphasis> with an ordinal specification
\r
551 enclosed in a brace pair (e.g. <emphasis>{1}</emphasis>, <emphasis>{15}</emphasis>) specifies
\r
552 the n-th prior value of that ref. For example <emphasis>master@{1}</emphasis>
\r
553 is the immediate prior value of <emphasis>master</emphasis> while <emphasis>master@{5}</emphasis>
\r
554 is the 5th prior value of <emphasis>master</emphasis>. This suffix may only be used
\r
555 immediately following a ref name and the ref must have an existing
\r
556 log (<emphasis>$GIT_DIR/logs/<refname></emphasis>).
\r
562 <emphasis>@{<n>}</emphasis>, e.g. <emphasis>@{1}</emphasis>
\r
566 You can use the <emphasis>@</emphasis> construct with an empty ref part to get at a
\r
567 reflog entry of the current branch. For example, if you are on
\r
568 branch <emphasis>blabla</emphasis> then <emphasis>@{1}</emphasis> means the same as <emphasis>blabla@{1}</emphasis>.
\r
574 <emphasis>@{-<n>}</emphasis>, e.g. <emphasis>@{-1}</emphasis>
\r
578 The construct <emphasis>@{-<n>}</emphasis> means the <n>th branch checked out
\r
579 before the current one.
\r
585 <emphasis><refname>@{upstream}</emphasis>, e.g. <emphasis>master@{upstream}</emphasis>, <emphasis>@{u}</emphasis>
\r
589 The suffix <emphasis>@{upstream}</emphasis> to a ref (short form <emphasis><refname>@{u}</emphasis>) refers to
\r
590 the branch the ref is set to build on top of. A missing ref defaults
\r
591 to the current branch.
\r
597 <emphasis><rev>^</emphasis>, e.g. <emphasis>HEAD^, v1.5.1^0</emphasis>
\r
601 A suffix <emphasis>^</emphasis> to a revision parameter means the first parent of
\r
602 that commit object. <emphasis>^<n></emphasis> means the <n>th parent (i.e.
\r
603 <emphasis><rev>^</emphasis>
\r
604 is equivalent to <emphasis><rev>^1</emphasis>). As a special rule,
\r
605 <emphasis><rev>^0</emphasis> means the commit itself and is used when <emphasis><rev></emphasis> is the
\r
606 object name of a tag object that refers to a commit object.
\r
612 <emphasis><rev>~<n></emphasis>, e.g. <emphasis>master~3</emphasis>
\r
616 A suffix <emphasis>~<n></emphasis> to a revision parameter means the commit
\r
617 object that is the <n>th generation ancestor of the named
\r
618 commit object, following only the first parents. I.e. <emphasis><rev>~3</emphasis> is
\r
619 equivalent to <emphasis><rev>^^^</emphasis> which is equivalent to
\r
620 <emphasis><rev>^1^1^1</emphasis>. See below for an illustration of
\r
621 the usage of this form.
\r
627 <emphasis><rev>^{<type>}</emphasis>, e.g. <emphasis>v0.99.8^{commit}</emphasis>
\r
631 A suffix <emphasis>^</emphasis> followed by an object type name enclosed in
\r
632 brace pair means the object
\r
633 could be a tag, and dereference the tag recursively until an
\r
634 object of that type is found or the object cannot be
\r
635 dereferenced anymore (in which case, barf). <emphasis><rev>^0</emphasis>
\r
636 is a short-hand for <emphasis><rev>^{commit}</emphasis>.
\r
642 <emphasis><rev>^{}</emphasis>, e.g. <emphasis>v0.99.8^{}</emphasis>
\r
646 A suffix <emphasis>^</emphasis> followed by an empty brace pair
\r
647 means the object could be a tag,
\r
648 and dereference the tag recursively until a non-tag object is
\r
655 <emphasis><rev>^{/<text>}</emphasis>, e.g. <emphasis>HEAD^{/fix nasty bug}</emphasis>
\r
659 A suffix <emphasis>^</emphasis> to a revision parameter, followed by a brace
\r
660 pair that contains a text led by a slash,
\r
661 is the same as the <emphasis>:/fix nasty bug</emphasis> syntax below except that
\r
662 it returns the youngest matching commit which is reachable from
\r
663 the <emphasis><rev></emphasis> before <emphasis>^</emphasis>.
\r
669 <emphasis>:/<text></emphasis>, e.g. <emphasis>:/fix nasty bug</emphasis>
\r
673 A colon, followed by a slash, followed by a text, names
\r
674 a commit whose commit message matches the specified regular expression.
\r
675 This name returns the youngest matching commit which is
\r
676 reachable from any ref. If the commit message starts with a
\r
677 <emphasis>!</emphasis> you have to repeat that; the special sequence <emphasis>:/!</emphasis>,
\r
678 followed by something else than <emphasis>!</emphasis>, is reserved for now.
\r
679 The regular expression can match any part of the commit message. To
\r
680 match messages starting with a string, one can use e.g. <emphasis>:/^foo</emphasis>.
\r
686 <emphasis><rev>:<path></emphasis>, e.g. <emphasis>HEAD:README</emphasis>, <emphasis>:README</emphasis>, <emphasis>master:./README</emphasis>
\r
690 A suffix <emphasis>:</emphasis> followed by a path names the blob or tree
\r
691 at the given path in the tree-ish object named by the part
\r
693 <emphasis>:path</emphasis> (with an empty part before the colon)
\r
694 is a special case of the syntax described next: content
\r
695 recorded in the index at the given path.
\r
696 A path starting with <emphasis>./</emphasis> or <emphasis>../</emphasis> is relative to the current working directory.
\r
697 The given path will be converted to be relative to the working tree's root directory.
\r
698 This is most useful to address a blob or tree from a commit or tree that has
\r
699 the same tree structure as the working tree.
\r
705 <emphasis>:<n>:<path></emphasis>, e.g. <emphasis>:0:README</emphasis>, <emphasis>:README</emphasis>
\r
709 A colon, optionally followed by a stage number (0 to 3) and a
\r
710 colon, followed by a path, names a blob object in the
\r
711 index at the given path. A missing stage number (and the colon
\r
712 that follows it) names a stage 0 entry. During a merge, stage
\r
713 1 is the common ancestor, stage 2 is the target branch's version
\r
714 (typically the current branch), and stage 3 is the version from
\r
715 the branch which is being merged.
\r
720 <simpara>Here is an illustration, by Jon Loeliger. Both commit nodes B
\r
721 and C are parents of commit node A. Parent commits are ordered
\r
722 left-to-right.</simpara>
\r
723 <literallayout class="monospaced">G H I J
\r
733 <literallayout class="monospaced">A = = A^0
\r
736 D = A^^ = A^1^1 = A~2
\r
739 G = A^^^ = A^1^1^1 = A~3
\r
740 H = D^2 = B^^2 = A^^^2 = A~2^2
\r
741 I = F^ = B^3^ = A^^3^
\r
742 J = F^2 = B^3^2 = A^^3^2</literallayout>
\r
744 <simplesect id="_specifying_ranges">
\r
745 <title>SPECIFYING RANGES</title>
\r
746 <simpara>History traversing commands such as <emphasis>git log</emphasis> operate on a set
\r
747 of commits, not just a single commit. To these commands,
\r
748 specifying a single revision with the notation described in the
\r
749 previous section means the set of commits reachable from that
\r
750 commit, following the commit ancestry chain.</simpara>
\r
751 <simpara>To exclude commits reachable from a commit, a prefix <emphasis>^</emphasis>
\r
752 notation is used. E.g. <emphasis>^r1 r2</emphasis> means commits reachable
\r
753 from <emphasis>r2</emphasis> but exclude the ones reachable from <emphasis>r1</emphasis>.</simpara>
\r
754 <simpara>This set operation appears so often that there is a shorthand
\r
755 for it. When you have two commits <emphasis>r1</emphasis> and <emphasis>r2</emphasis> (named according
\r
756 to the syntax explained in SPECIFYING REVISIONS above), you can ask
\r
757 for commits that are reachable from r2 excluding those that are reachable
\r
758 from r1 by <emphasis>^r1 r2</emphasis> and it can be written as <emphasis>r1..r2</emphasis>.</simpara>
\r
759 <simpara>A similar notation <emphasis>r1...r2</emphasis> is called symmetric difference
\r
760 of <emphasis>r1</emphasis> and <emphasis>r2</emphasis> and is defined as
\r
761 <emphasis>r1 r2 --not $(git merge-base --all r1 r2)</emphasis>.
\r
762 It is the set of commits that are reachable from either one of
\r
763 <emphasis>r1</emphasis> or <emphasis>r2</emphasis> but not from both.</simpara>
\r
764 <simpara>Two other shorthands for naming a set that is formed by a commit
\r
765 and its parent commits exist. The <emphasis>r1^@</emphasis> notation means all
\r
766 parents of <emphasis>r1</emphasis>. <emphasis>r1^!</emphasis> includes commit <emphasis>r1</emphasis> but excludes
\r
767 all of its parents.</simpara>
\r
768 <simpara>Here are a handful of examples:</simpara>
\r
769 <literallayout class="monospaced">D G H D
\r
776 F^! D G H D F</literallayout>
\r
778 <simplesect id="_parseopt">
\r
779 <title>PARSEOPT</title>
\r
780 <simpara>In <emphasis>--parseopt</emphasis> mode, <emphasis>git rev-parse</emphasis> helps massaging options to bring to shell
\r
781 scripts the same facilities C builtins have. It works as an option normalizer
\r
782 (e.g. splits single switches aggregate values), a bit like <emphasis>getopt(1)</emphasis> does.</simpara>
\r
783 <simpara>It takes on the standard input the specification of the options to parse and
\r
784 understand, and echoes on the standard output a string suitable for <emphasis>sh(1)</emphasis> <emphasis>eval</emphasis>
\r
785 to replace the arguments with normalized ones. In case of error, it outputs
\r
786 usage on the standard error stream, and exits with code 129.</simpara>
\r
787 <simpara>Note: Make sure you quote the result when passing it to <emphasis>eval</emphasis>. See
\r
788 below for an example.</simpara>
\r
789 <section id="_input_format">
\r
790 <title>Input Format</title>
\r
791 <simpara><emphasis>git rev-parse --parseopt</emphasis> input format is fully text based. It has two parts,
\r
792 separated by a line that contains only <emphasis>--</emphasis>. The lines before the separator
\r
793 (should be more than one) are used for the usage.
\r
794 The lines after the separator describe the options.</simpara>
\r
795 <simpara>Each line of options has this format:</simpara>
\r
796 <screen><opt_spec><flags>* SP+ help LF</screen>
\r
800 <emphasis><opt_spec></emphasis>
\r
804 its format is the short option character, then the long option name
\r
805 separated by a comma. Both parts are not required, though at least one
\r
806 is necessary. <emphasis>h,help</emphasis>, <emphasis>dry-run</emphasis> and <emphasis>f</emphasis> are all three correct
\r
807 <emphasis><opt_spec></emphasis>.
\r
813 <emphasis><flags></emphasis>
\r
817 <emphasis><flags></emphasis> are of <emphasis>*</emphasis>, <emphasis>=</emphasis>, <emphasis>?</emphasis> or <emphasis>!</emphasis>.
\r
822 Use <emphasis>=</emphasis> if the option takes an argument.
\r
827 Use <emphasis>?</emphasis> to mean that the option is optional (though its use is discouraged).
\r
832 Use <emphasis>*</emphasis> to mean that this option should not be listed in the usage
\r
833 generated for the <emphasis>-h</emphasis> argument. It's shown for <emphasis>--help-all</emphasis> as
\r
834 documented in <xref linkend="gitcli(7)" />.
\r
839 Use <emphasis>!</emphasis> to not make the corresponding negated long option available.
\r
846 <simpara>The remainder of the line, after stripping the spaces, is used
\r
847 as the help associated to the option.</simpara>
\r
848 <simpara>Blank lines are ignored, and lines that don't match this specification are used
\r
849 as option group headers (start the line with a space to create such
\r
850 lines on purpose).</simpara>
\r
852 <section id="_example">
\r
853 <title>Example</title>
\r
854 <screen>OPTS_SPEC="\
\r
855 some-command [options] <args>...
\r
857 some-command does foo and bar!
\r
859 h,help show the help
\r
861 foo some nifty option --foo
\r
862 bar= some cool option --bar with an argument
\r
864 An option group Header
\r
865 C? option C with an optional argument"
\r
867 eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"</screen>
\r
870 <simplesect id="_sq_quote">
\r
871 <title>SQ-QUOTE</title>
\r
872 <simpara>In <emphasis>--sq-quote</emphasis> mode, <emphasis>git rev-parse</emphasis> echoes on the standard output a
\r
873 single line suitable for <emphasis>sh(1)</emphasis> <emphasis>eval</emphasis>. This line is made by
\r
874 normalizing the arguments following <emphasis>--sq-quote</emphasis>. Nothing other than
\r
875 quoting the arguments is done.</simpara>
\r
876 <simpara>If you want command input to still be interpreted as usual by
\r
877 <emphasis>git rev-parse</emphasis> before the output is shell quoted, see the <emphasis>--sq</emphasis>
\r
879 <section id="_example_2">
\r
880 <title>Example</title>
\r
881 <screen>$ cat >your-git-script.sh <<\EOF
\r
883 args=$(git rev-parse --sq-quote "$@") # quote user-supplied arguments
\r
884 command="git frotz -n24 $args" # and use it inside a handcrafted
\r
889 $ sh your-git-script.sh "a b'c"</screen>
\r
892 <simplesect id="_examples">
\r
893 <title>EXAMPLES</title>
\r
897 Print the object name of the current commit:
\r
899 <screen>$ git rev-parse --verify HEAD</screen>
\r
903 Print the commit object name from the revision in the $REV shell variable:
\r
905 <screen>$ git rev-parse --verify $REV</screen>
\r
906 <simpara>This will error out if $REV is empty or not a valid revision.</simpara>
\r
912 <screen>$ git rev-parse --default master --verify $REV</screen>
\r
913 <simpara>but if $REV is empty, the commit object name from master will be printed.</simpara>
\r
917 <simplesect id="_git">
\r
919 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r