Re: [PATCH] sha1_name: don't resolve refs when core.warnambiguousrefs is false
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 7, 2014, 17:24 UTC
- Message-ID
- <xmqqd2k3g0ww.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <1389065521-46331-1-git-send-email-brodie@sf.io>
Brodie Rao <brodie@sf.io> writes:
Show 8 quoted lines
> This change ensures get_sha1_basic() doesn't try to resolve full hashes > as refs when ambiguous ref warnings are disabled. > > This provides a substantial performance improvement when passing many > hashes to a command (like "git rev-list --stdin") when > core.warnambiguousrefs is false. The check incurs 6 stat()s for every > hash supplied, which can be costly over NFS. > ---
Needs sign-off. The patch looks good.
Thanks.
Show 19 quoted lines
> sha1_name.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sha1_name.c b/sha1_name.c
> index e9c2999..10bd007 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -451,9 +451,9 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
> 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));