Skip to content

Commit 7cd895e

Browse files
committed
Merge branch 'mh/rev-parse-verify-doc'
"rev-parse --verify" was documented in a misleading way. * mh/rev-parse-verify-doc: rev-parse: clarify documentation for the --verify option
2 parents d5fec92 + 2db6067 commit 7cd895e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Documentation/git-rev-parse.txt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,19 @@ OPTIONS
6060
instead.
6161

6262
--verify::
63-
The parameter given must be usable as a single, valid
64-
object name. Otherwise barf and abort.
63+
Verify that exactly one parameter is provided, and that it
64+
can be turned into a raw 20-byte SHA-1 that can be used to
65+
access the object database. If so, emit it to the standard
66+
output; otherwise, error out.
67+
+
68+
If you want to make sure that the output actually names an object in
69+
your object database and/or can be used as a specific type of object
70+
you require, you can add "^{type}" peeling operator to the parmeter.
71+
For example, `git rev-parse "$VAR^{commit}"` will make sure `$VAR`
72+
names an existing object that is a commit-ish (i.e. a commit, or an
73+
annotated tag that points at a commit). To make sure that `$VAR`
74+
names an existing object of any type, `git rev-parse "$VAR^{object}"`
75+
can be used.
6576

6677
-q::
6778
--quiet::
@@ -308,12 +319,12 @@ $ git rev-parse --verify HEAD
308319
* Print the commit object name from the revision in the $REV shell variable:
309320
+
310321
------------
311-
$ git rev-parse --verify $REV
322+
$ git rev-parse --verify $REV^{commit}
312323
------------
313324
+
314325
This will error out if $REV is empty or not a valid revision.
315326

316-
* Same as above:
327+
* Similar to above:
317328
+
318329
------------
319330
$ git rev-parse --default master --verify $REV

0 commit comments

Comments
 (0)