Michael Haggerty <mhagger@xxxxxxxxxxxx> writes: > On 04/02/2013 05:45 PM, Junio C Hamano wrote: > >> Also, v1.8.2^{tag} would be give the tag itself, while master^{tag} >> would not report the commit "master" but would error out, which >> would be useless. You are better off doing `git cat-file -t foo` >> and seeing if it is a tag object at that point. > > All correct, of course. But the user would never use "master^{tag}" > unless he wants a tag and nothing else, so erroring out would be exactly > the thing he wants in that case. This is no different than the > "^{commit}" part of "master^{tree}^{commit}", which correctly errors out > because a commit cannot be inferred from a tree. Correct; I was only saying adding it is not something that solves a problem that cannot be solved with the current system (i.e. no added value from feature point-of-view). I would not object to a patch to allow "git rev-parse v1.8.2^{tag}" for completeness. We may want to rethink if we can lose the hardcoded lengths like 6, 3, 4, 4 from here, but I didn't bother ;-). sha1_name.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sha1_name.c b/sha1_name.c index 85b6e75..47f39a8 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -639,16 +639,18 @@ static int peel_onion(const char *name, int len, unsigned char *sha1) return -1; sp++; /* beginning of type name, or closing brace for empty */ - if (!strncmp(commit_type, sp, 6) && sp[6] == '}') + if (!strncmp(tag_type, sp, 3) && sp[3] == '}') + expected_type = OBJ_TAG; + else if (!strncmp(commit_type, sp, 6) && sp[6] == '}') expected_type = OBJ_COMMIT; else if (!strncmp(tree_type, sp, 4) && sp[4] == '}') expected_type = OBJ_TREE; else if (!strncmp(blob_type, sp, 4) && sp[4] == '}') expected_type = OBJ_BLOB; else if (!prefixcmp(sp, "object}")) - expected_type = OBJ_ANY; + expected_type = OBJ_ANY; /* ok as long as it exists */ else if (sp[0] == '}') - expected_type = OBJ_NONE; + expected_type = OBJ_NONE; /* unwrap until we get a non-tag */ else if (sp[0] == '/') expected_type = OBJ_COMMIT; else -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html