From: Junio C Hamano Date: Mon, 13 Jan 2014 19:33:29 +0000 (-0800) Subject: Merge branch 'br/sha1-name-40-hex-no-disambiguation' X-Git-Tag: v1.9-rc0~16 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0a8cb0355589cd4058be8b810a9fc608ef9b9a6c?hp=-c Merge branch 'br/sha1-name-40-hex-no-disambiguation' When parsing a 40-hex string into the object name, the string is checked to see if it can be interpreted as a ref so that a warning can be given for ambiguity. The code kicked in even when the core.warnambiguousrefs is set to false to squelch this warning, in which case the cycles spent to look at the ref namespace were an expensive no-op, as the result was discarded without being used. * br/sha1-name-40-hex-no-disambiguation: sha1_name: don't resolve refs when core.warnambiguousrefs is false --- 0a8cb0355589cd4058be8b810a9fc608ef9b9a6c diff --combined sha1_name.c index b1873d8113,10bd007162..a5578f718e --- a/sha1_name.c +++ b/sha1_name.c @@@ -451,9 -451,9 +451,9 @@@ static int get_sha1_basic(const char *s int at, reflog_len, nth_prior = 0; if (len == 40 && !get_sha1_hex(str, sha1)) { - if (warn_on_object_refname_ambiguity) { + if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) { refs_found = dwim_ref(str, len, tmp_sha1, &real_ref); - if (refs_found > 0 && warn_ambiguous_refs) { + if (refs_found > 0) { warning(warn_msg, len, str); if (advice_object_name_warning) fprintf(stderr, "%s\n", _(object_name_msg)); @@@ -546,7 -546,7 +546,7 @@@ if (read_ref_at(real_ref, at_time, nth, sha1, NULL, &co_time, &co_tz, &co_cnt)) { if (!len) { - if (!prefixcmp(real_ref, "refs/heads/")) { + if (starts_with(real_ref, "refs/heads/")) { str = real_ref + 11; len = strlen(real_ref + 11); } else { @@@ -581,6 -581,8 +581,6 @@@ static int get_parent(const char *name if (ret) return ret; commit = lookup_commit_reference(sha1); - if (!commit) - return -1; if (parse_commit(commit)) return -1; if (!idx) { @@@ -674,15 -676,15 +674,15 @@@ static int peel_onion(const char *name return -1; sp++; /* beginning of type name, or closing brace for empty */ - if (!prefixcmp(sp, "commit}")) + if (starts_with(sp, "commit}")) expected_type = OBJ_COMMIT; - else if (!prefixcmp(sp, "tag}")) + else if (starts_with(sp, "tag}")) expected_type = OBJ_TAG; - else if (!prefixcmp(sp, "tree}")) + else if (starts_with(sp, "tree}")) expected_type = OBJ_TREE; - else if (!prefixcmp(sp, "blob}")) + else if (starts_with(sp, "blob}")) expected_type = OBJ_BLOB; - else if (!prefixcmp(sp, "object}")) + else if (starts_with(sp, "object}")) expected_type = OBJ_ANY; else if (sp[0] == '}') expected_type = OBJ_NONE; @@@ -909,7 -911,7 +909,7 @@@ static int grab_nth_branch_switch(unsig const char *match = NULL, *target = NULL; size_t len; - if (!prefixcmp(message, "checkout: moving from ")) { + if (starts_with(message, "checkout: moving from ")) { match = message + strlen("checkout: moving from "); target = strstr(match, " to "); } @@@ -1302,7 -1304,7 +1302,7 @@@ static void diagnose_invalid_index_path static char *resolve_relative_path(const char *rel) { - if (prefixcmp(rel, "./") && prefixcmp(rel, "../")) + if (!starts_with(rel, "./") && !starts_with(rel, "../")) return NULL; if (!startup_info)