git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] rev-parse: clarify documentation for the --verify option

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Mar 30, 2013, 06:44 UTC
Message-ID
<1364625865-8459-1-git-send-email-mhagger@alum.mit.edu>

The old version could be read to mean that the argument has to refer to a valid object, but that is incorrect:

* the object is not necessarily read (e.g., to check for corruption)
* if the argument is a 40-digit string of hex digits, then it is
  accepted whether or not is is the name of an existing object.
So reword the explanation to be less ambiguous.

Also fix the examples involving --verify: to be sure that the argument refers to a commit (rather than some other kind of object), the argument has to be suffixed with "^{commit}". This trick is not possible in the example involving --default, so don't imply that it is exactly the same as the previous example.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
This was discussed in the following thread:
    http://thread.gmane.org/gmane.comp.version-control.git/219409

Please note that the second example already reveals a fly in the ointment:

    $ git rev-parse --default master --verify $REV
Following Junio's advice, we would like to change this to
    $ git rev-parse --default master --verify $REV^{commit}
but that defeats the purpose of the --default option.  Doing
    $ git rev-parse --verify $(git rev-parse --default master $REV)^{commit}

is just plain ugly. Though honestly, I don't see the point of using --default as opposed to

    $ git rev-parse --verify ${REV:-master}^{commit}

So maybe the second example should be removed entirely or converted to use ${REV:-master} rather than --default.

 Documentation/git-rev-parse.txt | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 10a116f..6095227 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -60,8 +60,10 @@ OPTIONS
 	instead.
 
 --verify::
-	The parameter given must be usable as a single, valid
-	object name.  Otherwise barf and abort.
+	If the parameter can be used as a single object name, output
+	that name; otherwise, emit an error message and exit with a
+	non-zero status.  Please note that the existence and validity
+	of the named object itself are not checked.
 
 -q::
 --quiet::
@@ -308,12 +310,12 @@ $ git rev-parse --verify HEAD
 * Print the commit object name from the revision in the $REV shell variable:
 +
 ------------
-$ git rev-parse --verify $REV
+$ git rev-parse --verify $REV^{commit}
 ------------
 +
 This will error out if $REV is empty or not a valid revision.
 
-* Same as above:
+* Similar to above:
 +
 ------------
 $ git rev-parse --default master --verify $REV
-- 
1.8.2
Next: Junio C Hamano
Message 1 of 6 in “rev-parse: clarify documentation for the --verify option”
  1. rev-parse: clarify documentation for the --verify optionMichael Haggerty, Mar 30, 2013
  2. Junio C HamanoMar 31, 2013
  3. Junio C HamanoApr 1, 2013
  4. Michael HaggertyApr 2, 2013
  5. Junio C HamanoApr 2, 2013
  6. Michael HaggertyApr 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.