X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-show-ref.c;h=65051d14fde44c14d12099df656ac423bc1c347e;hb=95f9b92700585eb9afa6978c350dc07ec5769ec6;hp=75211e64f9a850be95de3b85edaafdf0d9a5886a;hpb=3ed02de2f46105cbc45fcc8f3287513f470eb4a3;p=git.git diff --git a/builtin-show-ref.c b/builtin-show-ref.c index 75211e64f..65051d14f 100644 --- a/builtin-show-ref.c +++ b/builtin-show-ref.c @@ -1,3 +1,4 @@ +#include "builtin.h" #include "cache.h" #include "refs.h" #include "object.h" @@ -28,8 +29,8 @@ static int show_ref(const char *refname, const unsigned char *sha1, int flag, vo if (tags_only || heads_only) { int match; - match = heads_only && !strncmp(refname, "refs/heads/", 11); - match |= tags_only && !strncmp(refname, "refs/tags/", 10); + match = heads_only && !prefixcmp(refname, "refs/heads/"); + match |= tags_only && !prefixcmp(refname, "refs/tags/"); if (!match) return 0; } @@ -178,8 +179,8 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix) hash_only = 1; continue; } - if (!strncmp(arg, "--hash=", 7) || - (!strncmp(arg, "--abbrev", 8) && + if (!prefixcmp(arg, "--hash=") || + (!prefixcmp(arg, "--abbrev") && (arg[8] == '=' || arg[8] == '\0'))) { if (arg[2] != 'h' && !arg[8]) /* --abbrev only */ @@ -215,7 +216,7 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix) } if (!strcmp(arg, "--exclude-existing")) return exclude_existing(NULL); - if (!strncmp(arg, "--exclude-existing=", 19)) + if (!prefixcmp(arg, "--exclude-existing=")) return exclude_existing(arg + 19); usage(show_ref_usage); } @@ -226,7 +227,7 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix) while (*pattern) { unsigned char sha1[20]; - if (!strncmp(*pattern, "refs/", 5) && + if (!prefixcmp(*pattern, "refs/") && resolve_ref(*pattern, sha1, 1, NULL)) { if (!quiet) show_one(*pattern, sha1);