git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 07/10] rev-list: call new "filter_skip" function

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 26, 2009, 06:49 UTC
Message-ID
<7v8wmssrrs.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20090326055549.e1f244d9.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
Show 38 quoted lines
> This patch implements a new "filter_skip" function in C in
> "bisect.c" that will later replace the existing implementation in
> shell in "git-bisect.sh".
>
> An array is used to store the skipped commits. But the array is
> not yet fed anything.
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
>  bisect.c           |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  bisect.h           |    6 ++++-
>  builtin-rev-list.c |   30 ++++++++++++++++++++----
>  3 files changed, 95 insertions(+), 6 deletions(-)
>
> diff --git a/bisect.c b/bisect.c
> index 27def7d..39189f2 100644
> --- a/bisect.c
> +++ b/bisect.c
> @@ -4,6 +4,11 @@
>  #include "revision.h"
>  #include "bisect.h"
>  
> +
> +static unsigned char (*skipped_sha1)[20];
> +static int skipped_sha1_nr;
> +static int skipped_sha1_alloc;
> +
>  /* bits #0-15 in revision.h */
>  
>  #define COUNTED		(1u<<16)
> @@ -386,3 +391,63 @@ struct commit_list *find_bisection(struct commit_list *list,
>  	return best;
>  }
>  
> +static int skipcmp(const void *a, const void *b)
> +{
> +	return hashcmp(a, b);
> +}

I've learned to suspect without reading a qsort() callback that does not derefence its arguments. Is this doing the right thing?

Show 23 quoted lines
> +
> +static void prepare_skipped(void)
> +{
> +	qsort(skipped_sha1, skipped_sha1_nr, sizeof(*skipped_sha1), skipcmp);
> +}
> +
> +static int lookup_skipped(unsigned char *sha1)
> +{
> +	int lo, hi;
> +	lo = 0;
> +	hi = skipped_sha1_nr;
> +	while (lo < hi) {
> +		int mi = (lo + hi) / 2;
> +		int cmp = hashcmp(sha1, skipped_sha1[mi]);
> +		if (!cmp)
> +			return mi;
> +		if (cmp < 0)
> +			hi = mi;
> +		else
> +			lo = mi + 1;
> +	}
> +	return -lo - 1;
> +}
Previous: Christian CouderNext: Christian Couder
Message 2 of 9 in “rev-list: call new "filter_skip" function”
  1. 07/10 rev-list: call new "filter_skip" functionChristian Couder, Mar 26, 2009
  2. Junio C HamanoMar 26, 2009
  3. Christian CouderMar 30, 2009
  4. Johannes SchindelinMar 30, 2009
  5. Christian CouderMar 31, 2009
  6. Johannes SchindelinMar 31, 2009
  7. Christian CouderApr 1, 2009
  8. Johannes SchindelinApr 1, 2009
  9. Christian CouderApr 2, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.