Re: [PATCH 3/8] Better Error Handling for add
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:55:38
greened@obbligato.org writes:
quoted
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.