git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org
Subject: Re: [RFC PATCH] for-each-ref: respect GIT_REF_PARANOIA setting
Date: Mon, 21 Mar 2022 13:33:04 -0700	[thread overview]
Message-ID: <xmqqzgljvyf3.fsf@gitster.g> (raw)
In-Reply-To: <7283f826198aaec94c847f0b26e228ace9a38433.1647880211.git.me@ttaylorr.com> (Taylor Blau's message of "Mon, 21 Mar 2022 12:30:18 -0400")

Taylor Blau <me@ttaylorr.com> writes:

> +	ret = filter_refs(&array, &filter, FILTER_REFS_ALL);
> +	if (ret)
> +		goto cleanup;
>  	ref_array_sort(sorting, &array);

Fixing the "regression" would be a simple matter of removing the
early return from here, and instead show what we have collected?

>  	if (!maxcount || array.nr < maxcount)
> @@ -91,11 +93,12 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
>  		putchar('\n');
>  	}
>  
> +cleanup:
>  	strbuf_release(&err);
>  	strbuf_release(&output);
>  	ref_array_clear(&array);
>  	free_commit_list(filter.with_commit);
>  	free_commit_list(filter.no_commit);
>  	ref_sorting_release(sorting);
> -	return 0;
> +	return ret;
>  }
> diff --git a/ref-filter.c b/ref-filter.c
> index 7838bd22b8..f9667f6ca4 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -2249,7 +2249,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
>  
>  	if (flag & REF_ISBROKEN) {
>  		warning(_("ignoring broken ref %s"), refname);
> -		return 0;
> +		return 1;
>  	}

Ah, no, not really.  This causes us to stop iterating prematurely.

If we are iterating because we want to find any breakage, such an
early stop in iteration makes good sense, but most of the time, we
are not, and it is questionable if such an early return makes much
sense.

I suspect that a handler may need to keep going, while recording a
bit for each ref it collects.  ref_array_item may or may not have (I
do not know offhand) already a bit in its flag word to signal a broken
ref that we can carry this information out to the callers?

      parent reply	other threads:[~2022-03-21 20:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 16:30 [RFC PATCH] for-each-ref: respect GIT_REF_PARANOIA setting Taylor Blau
2022-03-21 17:29 ` Ævar Arnfjörð Bjarmason
2022-03-21 20:33 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqzgljvyf3.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=me@ttaylorr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).