diff options
Diffstat (limited to 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/sha1_name.c b/sha1_name.c index 5b004f513b..6d10f052b5 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -372,10 +372,10 @@ const char *find_unique_abbrev(const unsigned char *sha1, int len) int status, exists; static char hex[41]; - exists = has_sha1_file(sha1); memcpy(hex, sha1_to_hex(sha1), 40); if (len == 40 || !len) return hex; + exists = has_sha1_file(sha1); while (len < 40) { unsigned char sha1_ret[20]; status = get_short_sha1(hex, len, sha1_ret, GET_SHA1_QUIETLY); @@ -757,7 +757,7 @@ static int get_describe_name(const char *name, int len, unsigned char *sha1) for (cp = name + len - 1; name + 2 <= cp; cp--) { char ch = *cp; - if (hexval(ch) & ~0377) { + if (!isxdigit(ch)) { /* We must be looking at g in "SOMETHING-g" * for it to be describe output. */ @@ -993,7 +993,7 @@ int get_sha1_mb(const char *name, unsigned char *sha1) two = lookup_commit_reference_gently(sha1_tmp, 0); if (!two) return -1; - mbs = get_merge_bases(one, two, 1); + mbs = get_merge_bases(one, two); if (!mbs || mbs->next) st = -1; else { @@ -1391,9 +1391,7 @@ static int get_sha1_with_context_1(const char *name, namelen = strlen(cp); } - strncpy(oc->path, cp, - sizeof(oc->path)); - oc->path[sizeof(oc->path)-1] = '\0'; + strlcpy(oc->path, cp, sizeof(oc->path)); if (!active_cache) read_cache(); @@ -1443,9 +1441,7 @@ static int get_sha1_with_context_1(const char *name, name, len); } hashcpy(oc->tree, tree_sha1); - strncpy(oc->path, filename, - sizeof(oc->path)); - oc->path[sizeof(oc->path)-1] = '\0'; + strlcpy(oc->path, filename, sizeof(oc->path)); free(new_filename); return ret; |