Re: [bug report] git-am applying maildir patches in reverse
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 2, 2013, 00:08 UTC
- Message-ID
- <7v1ubyek9n.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20130301233548.GA13422@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 11 quoted lines
> diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
> index 2d43278..772c668 100644
> --- a/builtin/mailsplit.c
> +++ b/builtin/mailsplit.c
> @@ -130,6 +130,26 @@ static int populate_maildir_list(struct string_list *list, const char *path)
> return 0;
> }
>
> +static int maildir_filename_cmp(const char *a, const char *b)
> +{
> + while (1) {It is somewhat funny that we do not need to check !*a or !*b in this loop. As long as readdir() does not return duplicates, we won't be comparing the same strings with this function, and we won't read past '\0' at the end of both a and b at the same time.
Show 16 quoted lines
> + if (isdigit(*a) && isdigit(*b)) {
> + long int na, nb;
> + na = strtol(a, (char **)&a, 10);
> + nb = strtol(b, (char **)&b, 10);
> + if (na != nb)
> + return na - nb;
> + /* strtol advanced our pointers */
> + }
> + else {
> + if (*a != *b)
> + return *a - *b;
> + a++;
> + b++;
> + }
> + }
> +}