Re: [PATCH 3/8] Better Error Handling for add
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 2, 2013, 02:21 UTC
- Message-ID
- <7vobh85np6.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <87obh8fs8e.fsf@waller.obbligato.org>
greened@obbligato.org writes:
Show 7 quoted lines
>> If you want to make sure you give a comit to add_commit, you can
>> probably say something like this:
>>
>> git rev-parse -q --verify "$1^{commit}" >/dev/null ||
>> die "'$1' does not refer to a commit"
>
> What does $1^{commit} mean?"$thing^{type}" tells Git to interpret the $thing as that type (and error out if it can't).
So v1.0.0^{commit} is a less cryptic way to say v1.0.0^0 (there is no need to say "zeroth parent of a commit is the commit itself? Yeah, it makes sort of sense" when you learn it).
"git cat-file -t junio-gpg-pub^{blob}" will say "blob", but you will get a failure from "git rev-parse v1.0.0^{blob}" as you can only dereference a tag that refers to a commit down to the comit and then to its top-level tree, but not to a single blob.
And you can ask for the tree object with v1.0.0^{tree}, for example.