+#include "builtin.h"
#include "cache.h"
#include "refs.h"
#include "object.h"
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;
}
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 */
}
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);
}
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);