Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756107AbXLUE7W (ORCPT ); Thu, 20 Dec 2007 23:59:22 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760207AbXLUE7B (ORCPT ); Thu, 20 Dec 2007 23:59:01 -0500 Received: from smtp2.linux-foundation.org ([207.189.120.14]:58021 "EHLO smtp2.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753325AbXLUE66 (ORCPT ); Thu, 20 Dec 2007 23:58:58 -0500 Date: Thu, 20 Dec 2007 20:58:42 -0800 (PST) From: Linus Torvalds To: Kyle McMartin , Junio C Hamano , Git Mailing List cc: Linux Kernel Mailing List Subject: Re: Linux 2.6.24-rc6 In-Reply-To: Message-ID: References: <20071221024805.GB8535@fattire.cabal.ca> <20071221030152.GC8535@fattire.cabal.ca> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1506 Lines: 52 On Thu, 20 Dec 2007, Linus Torvalds wrote: > > And here's the git patch to avoid this optimization when there is > context. Actually, the code to finding one '\n' is still needed to avoid the (pathological) case of getting a "\No newline", so scrap that one which was too aggressive, and use this (simpler) one instead. Not that it matters in real life, since nobody uses -U0, and "git blame" won't care. But let's get it right anyway ;) This whole function has had more bugs than it has lines. Linus --- xdiff-interface.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xdiff-interface.c b/xdiff-interface.c index 9ee877c..711029e 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -115,15 +115,18 @@ static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx) char *bp = b->ptr + b->size; long smaller = (a->size < b->size) ? a->size : b->size; + if (ctx) + return; + while (blk + trimmed <= smaller && !memcmp(ap - blk, bp - blk, blk)) { trimmed += blk; ap -= blk; bp -= blk; } - while (recovered < trimmed && 0 <= ctx) + while (recovered < trimmed) if (ap[recovered++] == '\n') - ctx--; + break; a->size -= (trimmed - recovered); b->size -= (trimmed - recovered); } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/