From: Junio C Hamano <gitster@pobox.com>
To: Christian Couder <chriscool@tuxfamily.org>
Cc: git@vger.kernel.org, John Tapsell <johnflux@gmail.com>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH 07/10] rev-list: call new "filter_skip" function
Date: Wed, 25 Mar 2009 23:49:11 -0700 [thread overview]
Message-ID: <7v8wmssrrs.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 20090326055549.e1f244d9.chriscool@tuxfamily.org
Christian Couder <chriscool@tuxfamily.org> writes:
> 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?
> +
> +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;
> +}
next prev parent reply other threads:[~2009-03-26 6:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-26 4:55 [PATCH 07/10] rev-list: call new "filter_skip" function Christian Couder
2009-03-26 6:49 ` Junio C Hamano [this message]
2009-03-30 3:26 ` Christian Couder
2009-03-30 7:54 ` Johannes Schindelin
2009-03-31 6:45 ` Christian Couder
2009-03-31 9:23 ` Johannes Schindelin
2009-04-01 6:09 ` Christian Couder
2009-04-01 14:36 ` Johannes Schindelin
2009-04-02 4:23 ` Christian Couder
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=7v8wmssrrs.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=johnflux@gmail.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).