From: Junio C Hamano Date: Fri, 20 Sep 2013 19:27:18 +0000 (-0700) Subject: Merge branch 'rh/peeling-tag-to-tag' X-Git-Tag: v1.8.5-rc0~102 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/638924fec2189f3f20ebf5d0ff4cc34ee551dd39?hp=-c Merge branch 'rh/peeling-tag-to-tag' Make "foo^{tag}" to peel a tag to itself, i.e. no-op., and fail if "foo" is not a tag. "git rev-parse --verify v1.0^{tag}" would be a more convenient way to say "test $(git cat-file -t v1.0) = tag". * rh/peeling-tag-to-tag: peel_onion: do not assume length of x_type globals peel_onion(): add support for ^{tag} --- 638924fec2189f3f20ebf5d0ff4cc34ee551dd39 diff --combined Documentation/revisions.txt index b0f4284cfb,b3322adf24..71dcd12ebd --- a/Documentation/revisions.txt +++ b/Documentation/revisions.txt @@@ -111,20 -111,19 +111,23 @@@ some output processing may assume ref n '{caret}\{\}', e.g. 'v0.99.8{caret}\{commit\}':: A suffix '{caret}' followed by an object type name enclosed in - brace pair means the object - could be a tag, and dereference the tag recursively until an - object of that type is found or the object cannot be - dereferenced anymore (in which case, barf). '{caret}0' + brace pair means dereference the object at '' recursively until + an object of type '' is found or the object cannot be + dereferenced anymore (in which case, barf). + For example, if '' is a commit-ish, '{caret}\{commit\}' + describes the corresponding commit object. + Similarly, if '' is a tree-ish, '{caret}\{tree\}' + describes the corresponding tree object. + '{caret}0' is a short-hand for '{caret}\{commit\}'. + 'rev{caret}\{object\}' can be used to make sure 'rev' names an object that exists, without requiring 'rev' to be a tag, and without dereferencing 'rev'; because a tag is already an object, it does not have to be dereferenced even once to get to an object. + + + 'rev{caret}\{tag\}' can be used to ensure that 'rev' identifies an + existing tag object. '{caret}\{\}', e.g. 'v0.99.8{caret}\{\}':: A suffix '{caret}' followed by an empty brace pair diff --combined sha1_name.c index ad79d7b812,2f6e5abaaf..78c093f79e --- a/sha1_name.c +++ b/sha1_name.c @@@ -677,11 -677,13 +677,13 @@@ static int peel_onion(const char *name return -1; sp++; /* beginning of type name, or closing brace for empty */ - if (!strncmp(commit_type, sp, 6) && sp[6] == '}') + if (!prefixcmp(sp, "commit}")) expected_type = OBJ_COMMIT; - else if (!strncmp(tree_type, sp, 4) && sp[4] == '}') + else if (!prefixcmp(sp, "tag}")) + expected_type = OBJ_TAG; + else if (!prefixcmp(sp, "tree}")) expected_type = OBJ_TREE; - else if (!strncmp(blob_type, sp, 4) && sp[4] == '}') + else if (!prefixcmp(sp, "blob}")) expected_type = OBJ_BLOB; else if (!prefixcmp(sp, "object}")) expected_type = OBJ_ANY; @@@ -1130,13 -1132,13 +1132,13 @@@ int get_sha1(const char *name, unsigne } /* - * Many callers know that the user meant to name a committish by + * Many callers know that the user meant to name a commit-ish by * syntactical positions where the object name appears. Calling this * function allows the machinery to disambiguate shorter-than-unique - * abbreviated object names between committish and others. + * abbreviated object names between commit-ish and others. * * Note that this does NOT error out when the named object is not a - * committish. It is merely to give a hint to the disambiguation + * commit-ish. It is merely to give a hint to the disambiguation * machinery. */ int get_sha1_committish(const char *name, unsigned char *sha1)