diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-09-20 12:27:18 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-09-20 12:27:18 -0700 |
commit | 638924fec2189f3f20ebf5d0ff4cc34ee551dd39 (patch) | |
tree | 3a7b24c2855c88f95885e5fc5f6bfd372d72097d /sha1_name.c | |
parent | 2e6e3e82ee36b3e1bec1db8db24817270080424e (diff) | |
parent | c969b6a18d1cde3ffb8a5ca5cd45a57052c2cc95 (diff) | |
download | git-638924fec2189f3f20ebf5d0ff4cc34ee551dd39.tar.gz |
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 <rev>^{tag}
Diffstat (limited to 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sha1_name.c b/sha1_name.c index ad79d7b812..78c093f79e 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -677,11 +677,13 @@ 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 (!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; |