diff options
author | René Scharfe <l.s.r@web.de> | 2014-10-04 20:54:50 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-10-07 11:09:16 -0700 |
commit | e3f1da982e4f14e7146964cb25a5011a3f41e84a (patch) | |
tree | 0b225c25e7b86a7a49b58f4fa4af500c5c36b40a /builtin/cat-file.c | |
parent | 565301e41670825ceedf75220f2918ae76831240 (diff) | |
download | git-e3f1da982e4f14e7146964cb25a5011a3f41e84a.tar.gz |
use skip_prefix() to avoid more magic numbersrs/more-uses-of-skip-prefix
Continue where ae021d87 (use skip_prefix to avoid magic numbers) left off
and use skip_prefix() in more places for determining the lengths of prefix
strings to avoid using dependent constants and other indirect methods.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/cat-file.c')
-rw-r--r-- | builtin/cat-file.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 707330499f..f8d81291b9 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -82,8 +82,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name) enum object_type type; unsigned long size; char *buffer = read_sha1_file(sha1, &type, &size); - if (memcmp(buffer, "object ", 7) || - get_sha1_hex(buffer + 7, blob_sha1)) + const char *target; + if (!skip_prefix(buffer, "object ", &target) || + get_sha1_hex(target, blob_sha1)) die("%s not a valid tag", sha1_to_hex(sha1)); free(buffer); } else |