1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.4.5" />
7 <title>git-rev-parse(
1)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 git-rev-parse(
1) Manual Page
409 <div class=
"sectionbody">
411 Pick out and massage parameters
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"paragraph"><p><em>git rev-parse
</em> [ --option ]
<args
>…</p></div>
419 <h2 id=
"_description">DESCRIPTION
</h2>
420 <div class=
"sectionbody">
421 <div class=
"paragraph"><p>Many git porcelainish commands take mixture of flags
422 (i.e. parameters that begin with a dash
<em>-
</em>) and parameters
423 meant for the underlying
<em>git rev-list
</em> command they use internally
424 and flags and parameters for the other commands they use
425 downstream of
<em>git rev-list
</em>. This command is used to
426 distinguish between them.
</p></div>
428 <h2 id=
"_options">OPTIONS
</h2>
429 <div class=
"sectionbody">
430 <div class=
"dlist"><dl>
436 Use
<em>git rev-parse
</em> in option parsing mode (see PARSEOPT section below).
444 Only meaningful in
<tt>--parseopt
</tt> mode. Tells the option parser to echo
445 out the first
<tt>--
</tt> met instead of skipping it.
453 Only meaningful in
<tt>--parseopt
</tt> mode. Lets the option parser stop at
454 the first non-option argument. This can be used to parse sub-commands
455 that take options themselves.
463 Use
<em>git rev-parse
</em> in shell quoting mode (see SQ-QUOTE
464 section below). In contrast to the
<tt>--sq
</tt> option below, this
465 mode does only quoting. Nothing else is done to command input.
473 Do not output flags and parameters not meant for
474 <em>git rev-list
</em> command.
482 Do not output flags and parameters meant for
483 <em>git rev-list
</em> command.
491 Do not output non-flag parameters.
499 Do not output flag parameters.
503 --default
<arg
>
507 If there is no parameter given by the user, use
<tt><arg
></tt>
516 The parameter given must be usable as a single, valid
517 object name. Otherwise barf and abort.
528 Only meaningful in
<tt>--verify
</tt> mode. Do not output an error
529 message if the first argument is not a valid object name;
530 instead exit with non-zero status silently.
538 Usually the output is made one line per flag and
539 parameter. This option makes output a single line,
540 properly quoted for consumption by shell. Useful when
541 you expect your parameter to contain whitespaces and
542 newlines (e.g. when using pickaxe
<tt>-S
</tt> with
543 <em>git diff-
*</em>). In contrast to the
<tt>--sq-quote
</tt> option,
544 the command input is still interpreted as usual.
552 When showing object names, prefix them with
<em>^</em> and
553 strip
<em>^</em> prefix from the object names that already have
562 Usually the object names are output in SHA1 form (with
563 possible
<em>^</em> prefix); this option makes them output in a
564 form as close to the original input as possible.
572 This is similar to --symbolic, but it omits input that
573 are not refs (i.e. branch or tag names; or more
574 explicitly disambiguating
"heads/master" form, when you
575 want to name the
"master" branch when there is an
576 unfortunately named tag
"master"), and show them as full
577 refnames (e.g.
"refs/heads/master").
581 --abbrev-ref[=(strict|loose)]
585 A non-ambiguous short name of the objects name.
586 The option core.warnAmbiguousRefs is used to select the strict
595 Show all refs found in
<tt>refs/
</tt>.
609 Show all branches, tags, or remote-tracking branches,
610 respectively (i.e., refs found in
<tt>refs/heads
</tt>,
611 <tt>refs/tags
</tt>, or
<tt>refs/remotes
</tt>, respectively).
613 <div class=
"paragraph"><p>If a
<tt>pattern
</tt> is given, only refs matching the given shell glob are
614 shown. If the pattern does not contain a globbing character (
<tt>?
</tt>,
615 <tt>*</tt>, or
<tt>[
</tt>), it is turned into a prefix match by
616 appending
<tt>/
*</tt>.
</p></div>
623 Show all refs matching the shell glob pattern
<tt>pattern
</tt>. If
624 the pattern does not start with
<tt>refs/
</tt>, this is automatically
625 prepended. If the pattern does not contain a globbing
626 character (
<tt>?
</tt>,
<tt>*</tt>, or
<tt>[
</tt>), it is turned into a prefix
627 match by appending
<tt>/
*</tt>.
635 Show the absolute path of the top-level directory.
643 When the command is invoked from a subdirectory, show the
644 path of the current directory relative to the top-level
653 When the command is invoked from a subdirectory, show the
654 path of the top-level directory relative to the current
655 directory (typically a sequence of
"../", or an empty string).
663 Show
<tt>$GIT_DIR
</tt> if defined. Otherwise show the path to
664 the .git directory, relative to the current directory.
666 <div class=
"paragraph"><p>If
<tt>$GIT_DIR
</tt> is not defined and the current directory
667 is not detected to lie in a git repository or work tree
668 print a message to stderr and exit with nonzero status.
</p></div>
675 When the current working directory is below the repository
676 directory print
"true", otherwise
"false".
680 --is-inside-work-tree
684 When the current working directory is inside the work tree of the
685 repository print
"true", otherwise
"false".
693 When the repository is bare print
"true", otherwise
"false".
701 List the GIT_* environment variables that are local to the
702 repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR).
703 Only the names of the variables are listed, not their value,
704 even if they are set.
715 Instead of outputting the full SHA1 values of object names try to
716 abbreviate them to a shorter unique name. When no length is specified
717 7 is used. The minimum length is
4.
728 Parse the date string, and output the corresponding
729 --max-age= parameter for
<em>git rev-list
</em>.
740 Parse the date string, and output the corresponding
741 --min-age= parameter for
<em>git rev-list
</em>.
749 Flags and parameters to be parsed.
754 <h2 id=
"_specifying_revisions">SPECIFYING REVISIONS
</h2>
755 <div class=
"sectionbody">
756 <div class=
"paragraph"><p>A revision parameter typically, but not necessarily, names a
757 commit object. They use what is called an
<em>extended SHA1
</em>
758 syntax. Here are various ways to spell object names. The
759 ones listed near the end of this list are to name trees and
760 blobs contained in a commit.
</p></div>
761 <div class=
"ulist"><ul>
764 The full SHA1 object name (
40-byte hexadecimal string), or
765 a substring of such that is unique within the repository.
766 E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both
767 name the same commit object if there are no other object in
768 your repository whose object name starts with dae86e.
773 An output from
<em>git describe
</em>; i.e. a closest tag, optionally
774 followed by a dash and a number of commits, followed by a dash, a
775 <tt>g
</tt>, and an abbreviated object name.
780 A symbolic ref name. E.g.
<em>master
</em> typically means the commit
781 object referenced by refs/heads/master. If you
782 happen to have both heads/master and tags/master, you can
783 explicitly say
<em>heads/master
</em> to tell git which one you mean.
784 When ambiguous, a
<tt><name
></tt> is disambiguated by taking the
785 first match in the following rules:
787 <div class=
"olist arabic"><ol class=
"arabic">
790 if
<tt>$GIT_DIR/
<name
></tt> exists, that is what you mean (this is usually
791 useful only for
<tt>HEAD
</tt>,
<tt>FETCH_HEAD
</tt>,
<tt>ORIG_HEAD
</tt>,
<tt>MERGE_HEAD
</tt>
792 and
<tt>CHERRY_PICK_HEAD
</tt>);
797 otherwise,
<tt>refs/
<name
></tt> if exists;
802 otherwise,
<tt>refs/tags/
<name
></tt> if exists;
807 otherwise,
<tt>refs/heads/
<name
></tt> if exists;
812 otherwise,
<tt>refs/remotes/
<name
></tt> if exists;
817 otherwise,
<tt>refs/remotes/
<name
>/HEAD
</tt> if exists.
819 <div class=
"paragraph"><p>HEAD names the commit your changes in the working tree is based on.
820 FETCH_HEAD records the branch you fetched from a remote repository
821 with your last
<em>git fetch
</em> invocation.
822 ORIG_HEAD is created by commands that moves your HEAD in a drastic
823 way, to record the position of the HEAD before their operation, so that
824 you can change the tip of the branch back to the state before you ran
826 MERGE_HEAD records the commit(s) you are merging into your branch
827 when you run
<em>git merge
</em>.
828 CHERRY_PICK_HEAD records the commit you are cherry-picking
829 when you run
<em>git cherry-pick
</em>.
</p></div>
830 <div class=
"paragraph"><p>Note that any of the
<tt>refs/*
</tt> cases above may come either from
831 the
<tt>$GIT_DIR/refs
</tt> directory or from the
<tt>$GIT_DIR/packed-refs
</tt> file.
</p></div>
837 A ref followed by the suffix
<em>@
</em> with a date specification
839 pair (e.g.
<em>{yesterday}
</em>,
<em>{
1 month
2 weeks
3 days
1 hour
1
840 second ago}
</em> or
<em>{
1979-
02-
26 18:
30:
00}
</em>) to specify the value
841 of the ref at a prior point in time. This suffix may only be
842 used immediately following a ref name and the ref must have an
843 existing log ($GIT_DIR/logs/
<ref
>). Note that this looks up the state
844 of your
<strong>local
</strong> ref at a given time; e.g., what was in your local
845 <tt>master
</tt> branch last week. If you want to look at commits made during
846 certain times, see
<tt>--since
</tt> and
<tt>--until
</tt>.
851 A ref followed by the suffix
<em>@
</em> with an ordinal specification
852 enclosed in a brace pair (e.g.
<em>{
1}
</em>,
<em>{
15}
</em>) to specify
853 the n-th prior value of that ref. For example
<em>master@{
1}
</em>
854 is the immediate prior value of
<em>master
</em> while
<em>master@{
5}
</em>
855 is the
5th prior value of
<em>master
</em>. This suffix may only be used
856 immediately following a ref name and the ref must have an existing
857 log ($GIT_DIR/logs/
<ref
>).
862 You can use the
<em>@
</em> construct with an empty ref part to get at a
863 reflog of the current branch. For example, if you are on the
864 branch
<em>blabla
</em>, then
<em>@{
1}
</em> means the same as
<em>blabla@{
1}
</em>.
869 The special construct
<em>@{-
<n
>}
</em> means the
<n
>th branch checked out
870 before the current one.
875 The suffix
<em>@{upstream}
</em> to a ref (short form
<em>ref@{u}
</em>) refers to
876 the branch the ref is set to build on top of. Missing ref defaults
877 to the current branch.
882 A suffix
<em>^</em> to a revision parameter (e.g.
<em>HEAD
^</em>) means the first parent of
883 that commit object.
<em>^<n
></em> means the
<n
>th parent (i.e.
885 is equivalent to
<em>rev
^1</em>). As a special rule,
886 <em>rev
^0</em> means the commit itself and is used when
<em>rev
</em> is the
887 object name of a tag object that refers to a commit object.
892 A suffix
<em>~<n
></em> to a revision parameter means the commit
893 object that is the
<n
>th generation grand-parent of the named
894 commit object, following only the first parent. I.e. rev~
3 is
895 equivalent to rev
^^^ which is equivalent to
896 rev
^1^1^1. See below for a illustration of
897 the usage of this form.
902 A suffix
<em>^</em> followed by an object type name enclosed in
903 brace pair (e.g.
<tt>v0.99
.8^{commit}
</tt>) means the object
904 could be a tag, and dereference the tag recursively until an
905 object of that type is found or the object cannot be
906 dereferenced anymore (in which case, barf).
<tt>rev
^0</tt>
907 introduced earlier is a short-hand for
<tt>rev
^{commit}
</tt>.
912 A suffix
<em>^</em> followed by an empty brace pair
913 (e.g.
<tt>v0.99
.8^{}
</tt>) means the object could be a tag,
914 and dereference the tag recursively until a non-tag object is
920 A suffix
<em>^</em> to a revision parameter followed by a brace
921 pair that contains a text led by a slash (e.g.
<tt>HEAD^{/fix nasty bug}
</tt>):
922 this is the same as
<tt>:/fix nasty bug
</tt> syntax below except that
923 it returns the youngest matching commit which is reachable from
924 the ref before
<em>^</em>.
929 A colon, followed by a slash, followed by a text (e.g.
<tt>:/fix nasty bug
</tt>): this names
930 a commit whose commit message matches the specified regular expression.
931 This name returns the youngest matching commit which is
932 reachable from any ref. If the commit message starts with a
933 <em>!
</em>, you have to repeat that; the special sequence
<em>:/!
</em>,
934 followed by something else than
<em>!
</em> is reserved for now.
935 The regular expression can match any part of the commit message. To
936 match messages starting with a string, one can use e.g.
<tt>:/^foo
</tt>.
941 A suffix
<em>:
</em> followed by a path (e.g.
<tt>HEAD:README
</tt>); this names the blob or tree
942 at the given path in the tree-ish object named by the part
944 <em>:path
</em> (with an empty part before the colon, e.g.
<tt>:README
</tt>)
945 is a special case of the syntax described next: content
946 recorded in the index at the given path.
947 A path starting with
<em>./
</em> or
<em>../
</em> is relative to current working directory.
948 The given path will be converted to be relative to working tree
’s root directory.
949 This is most useful to address a blob or tree from a commit or tree that has
950 the same tree structure with the working tree.
955 A colon, optionally followed by a stage number (
0 to
3) and a
956 colon, followed by a path (e.g.
<tt>:
0:README
</tt>); this names a blob object in the
957 index at the given path. Missing stage number (and the colon
958 that follows it, e.g.
<tt>:README
</tt>) names a stage
0 entry. During a merge, stage
959 1 is the common ancestor, stage
2 is the target branch
’s version
960 (typically the current branch), and stage
3 is the version from
961 the branch being merged.
965 <div class=
"paragraph"><p>Here is an illustration, by Jon Loeliger. Both commit nodes B
966 and C are parents of commit node A. Parent commits are ordered
967 left-to-right.
</p></div>
968 <div class=
"literalblock">
969 <div class=
"content">
981 <div class=
"literalblock">
982 <div class=
"content">
986 D = A^^ = A^
1^
1 = A~
2
989 G = A^^^ = A^
1^
1^
1 = A~
3
990 H = D^
2 = B^^
2 = A^^^
2 = A~
2^
2
991 I = F^ = B^
3^ = A^^
3^
992 J = F^
2 = B^
3^
2 = A^^
3^
2</tt></pre>
995 <h2 id=
"_specifying_ranges">SPECIFYING RANGES
</h2>
996 <div class=
"sectionbody">
997 <div class=
"paragraph"><p>History traversing commands such as
<em>git log
</em> operate on a set
998 of commits, not just a single commit. To these commands,
999 specifying a single revision with the notation described in the
1000 previous section means the set of commits reachable from that
1001 commit, following the commit ancestry chain.
</p></div>
1002 <div class=
"paragraph"><p>To exclude commits reachable from a commit, a prefix
<tt>^</tt>
1003 notation is used. E.g.
<tt>^r1 r2
</tt> means commits reachable
1004 from
<tt>r2
</tt> but exclude the ones reachable from
<tt>r1
</tt>.
</p></div>
1005 <div class=
"paragraph"><p>This set operation appears so often that there is a shorthand
1006 for it. When you have two commits
<tt>r1
</tt> and
<tt>r2
</tt> (named according
1007 to the syntax explained in SPECIFYING REVISIONS above), you can ask
1008 for commits that are reachable from r2 excluding those that are reachable
1009 from r1 by
<tt>^r1 r2
</tt> and it can be written as
<tt>r1..r2
</tt>.
</p></div>
1010 <div class=
"paragraph"><p>A similar notation
<tt>r1...r2
</tt> is called symmetric difference
1011 of
<tt>r1
</tt> and
<tt>r2
</tt> and is defined as
1012 <tt>r1 r2 --not $(git merge-base --all r1 r2)
</tt>.
1013 It is the set of commits that are reachable from either one of
1014 <tt>r1
</tt> or
<tt>r2
</tt> but not from both.
</p></div>
1015 <div class=
"paragraph"><p>Two other shorthands for naming a set that is formed by a commit
1016 and its parent commits exist. The
<tt>r1
^@
</tt> notation means all
1017 parents of
<tt>r1
</tt>.
<tt>r1
^!
</tt> includes commit
<tt>r1
</tt> but excludes
1018 all of its parents.
</p></div>
1019 <div class=
"paragraph"><p>Here are a handful of examples:
</p></div>
1020 <div class=
"literalblock">
1021 <div class=
"content">
1029 F^! D G H D F
</tt></pre>
1032 <h2 id=
"_parseopt">PARSEOPT
</h2>
1033 <div class=
"sectionbody">
1034 <div class=
"paragraph"><p>In
<tt>--parseopt
</tt> mode,
<em>git rev-parse
</em> helps massaging options to bring to shell
1035 scripts the same facilities C builtins have. It works as an option normalizer
1036 (e.g. splits single switches aggregate values), a bit like
<tt>getopt(
1)
</tt> does.
</p></div>
1037 <div class=
"paragraph"><p>It takes on the standard input the specification of the options to parse and
1038 understand, and echoes on the standard output a string suitable for
<tt>sh(
1)
</tt> <tt>eval
</tt>
1039 to replace the arguments with normalized ones. In case of error, it outputs
1040 usage on the standard error stream, and exits with code
129.
</p></div>
1041 <div class=
"paragraph"><p>Note: Make sure you quote the result when passing it to
<tt>eval
</tt>. See
1042 below for an example.
</p></div>
1043 <h3 id=
"_input_format">Input Format
</h3><div style=
"clear:left"></div>
1044 <div class=
"paragraph"><p><em>git rev-parse --parseopt
</em> input format is fully text based. It has two parts,
1045 separated by a line that contains only
<tt>--
</tt>. The lines before the separator
1046 (should be more than one) are used for the usage.
1047 The lines after the separator describe the options.
</p></div>
1048 <div class=
"paragraph"><p>Each line of options has this format:
</p></div>
1049 <div class=
"listingblock">
1050 <div class=
"content">
1051 <pre><tt><opt_spec
><flags
>* SP+ help LF
</tt></pre>
1053 <div class=
"dlist"><dl>
1054 <dt class=
"hdlist1">
1055 <tt><opt_spec
></tt>
1059 its format is the short option character, then the long option name
1060 separated by a comma. Both parts are not required, though at least one
1061 is necessary.
<tt>h,help
</tt>,
<tt>dry-run
</tt> and
<tt>f
</tt> are all three correct
1062 <tt><opt_spec
></tt>.
1065 <dt class=
"hdlist1">
1066 <tt><flags
></tt>
1070 <tt><flags
></tt> are of
<tt>*
</tt>,
<tt>=
</tt>,
<tt>?
</tt> or
<tt>!
</tt>.
1072 <div class=
"ulist"><ul>
1075 Use
<tt>=
</tt> if the option takes an argument.
1080 Use
<tt>?
</tt> to mean that the option is optional (though its use is discouraged).
1085 Use
<tt>*
</tt> to mean that this option should not be listed in the usage
1086 generated for the
<tt>-h
</tt> argument. It
’s shown for
<tt>--help-all
</tt> as
1087 documented in
<a href=
"gitcli.html">gitcli(
7)
</a>.
1092 Use
<tt>!
</tt> to not make the corresponding negated long option available.
1098 <div class=
"paragraph"><p>The remainder of the line, after stripping the spaces, is used
1099 as the help associated to the option.
</p></div>
1100 <div class=
"paragraph"><p>Blank lines are ignored, and lines that don
’t match this specification are used
1101 as option group headers (start the line with a space to create such
1102 lines on purpose).
</p></div>
1103 <h3 id=
"_example">Example
</h3><div style=
"clear:left"></div>
1104 <div class=
"listingblock">
1105 <div class=
"content">
1106 <pre><tt>OPTS_SPEC=
"\
1107 some-command [options] <args>...
1109 some-command does foo and bar!
1111 h,help show the help
1113 foo some nifty option --foo
1114 bar= some cool option --bar with an argument
1116 An option group Header
1117 C? option C with an optional argument"
1119 eval
"$(echo "$OPTS_SPEC
" | git rev-parse --parseopt -- "$@
" || echo exit $?)"</tt></pre>
1122 <h2 id=
"_sq_quote">SQ-QUOTE
</h2>
1123 <div class=
"sectionbody">
1124 <div class=
"paragraph"><p>In
<tt>--sq-quote
</tt> mode,
<em>git rev-parse
</em> echoes on the standard output a
1125 single line suitable for
<tt>sh(
1)
</tt> <tt>eval
</tt>. This line is made by
1126 normalizing the arguments following
<tt>--sq-quote
</tt>. Nothing other than
1127 quoting the arguments is done.
</p></div>
1128 <div class=
"paragraph"><p>If you want command input to still be interpreted as usual by
1129 <em>git rev-parse
</em> before the output is shell quoted, see the
<tt>--sq
</tt>
1131 <h3 id=
"_example_2">Example
</h3><div style=
"clear:left"></div>
1132 <div class=
"listingblock">
1133 <div class=
"content">
1134 <pre><tt>$ cat
>your-git-script.sh
<<\EOF
1136 args=$(git rev-parse --sq-quote
"$@") # quote user-supplied arguments
1137 command=
"git frotz -n24 $args" # and use it inside a handcrafted
1142 $ sh your-git-script.sh
"a b'c"</tt></pre>
1145 <h2 id=
"_examples">EXAMPLES
</h2>
1146 <div class=
"sectionbody">
1147 <div class=
"ulist"><ul>
1150 Print the object name of the current commit:
1152 <div class=
"listingblock">
1153 <div class=
"content">
1154 <pre><tt>$ git rev-parse --verify HEAD
</tt></pre>
1159 Print the commit object name from the revision in the $REV shell variable:
1161 <div class=
"listingblock">
1162 <div class=
"content">
1163 <pre><tt>$ git rev-parse --verify $REV
</tt></pre>
1165 <div class=
"paragraph"><p>This will error out if $REV is empty or not a valid revision.
</p></div>
1171 <div class=
"listingblock">
1172 <div class=
"content">
1173 <pre><tt>$ git rev-parse --default master --verify $REV
</tt></pre>
1175 <div class=
"paragraph"><p>but if $REV is empty, the commit object name from master will be printed.
</p></div>
1179 <h2 id=
"_git">GIT
</h2>
1180 <div class=
"sectionbody">
1181 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1184 <div id=
"footer-text">
1185 Last updated
2011-
03-
15 23:
30:
14 UTC