From mboxrd@z Thu Jan 1 00:00:00 1970 From: Giuseppe Bilotta Subject: [PATCHv3] git apply: option to ignore whitespace differences Date: Tue, 28 Jul 2009 23:00:20 +0200 Message-ID: <1248814820-25367-1-git-send-email-giuseppe.bilotta@gmail.com> Cc: Junio C Hamano , Giuseppe Bilotta To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Tue Jul 28 23:00:41 2009 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1MVtmq-0001iU-0x for gcvg-git-2@gmane.org; Tue, 28 Jul 2009 23:00:41 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752544AbZG1VA3 (ORCPT ); Tue, 28 Jul 2009 17:00:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750743AbZG1VA3 (ORCPT ); Tue, 28 Jul 2009 17:00:29 -0400 Received: from mail-fx0-f218.google.com ([209.85.220.218]:55189 "EHLO mail-fx0-f218.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750769AbZG1VA1 (ORCPT ); Tue, 28 Jul 2009 17:00:27 -0400 Received: by fxm18 with SMTP id 18so17556fxm.37 for ; Tue, 28 Jul 2009 14:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=+efNmzRQCH0ywNfDxwsRTUZbVBdnOfXk+Zh9MBsty5c=; b=nzfuSxPZbfyt96Hv/TTiQkK6O6X0VsiLJmcGVxZm1OG5U4IoHM0GTpsImDRX60Foe8 WF3puT0NZ/B+dGh+3e/k3ZxUIhiIoj9IDB3+YXLGLFDcjQ6JVzlpPWEoLhG0wgxTGbVt VUqO+e9FFf7OccrkJPZkwCWKq1kUQ3k9dSL8c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=Ii7bDWyxiG1UYCTQSM4PLroPIDca43fk7a1nlBO0hMPOdCU9aRaYdAFNPIc9m36cHj NBkLiF+j3tMQqyl7aJLgX6xxaEaRH4aqkddt5MF8TgeY9aUFI6p7rHHeIiutYrTx2oex 7mMaJ8CSRLzqaiFX0lFzHQFaOh87ujBPCXkTU= Received: by 10.103.167.14 with SMTP id u14mr4213410muo.81.1248814826583; Tue, 28 Jul 2009 14:00:26 -0700 (PDT) Received: from localhost (dynamic-adsl-94-37-27-183.clienti.tiscali.it [94.37.27.183]) by mx.google.com with ESMTPS id n7sm1199985mue.28.2009.07.28.14.00.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 28 Jul 2009 14:00:25 -0700 (PDT) X-Mailer: git-send-email 1.6.3.3.511.gcffae6.dirty Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Introduce --ignore-whitespace option and corresponding config bool to ignore whitespace differences while applying patches, akin to the 'patch' program. 'git am', 'git rebase' and the bash git completion are made aware of this option. Signed-off-by: Giuseppe Bilotta --- Third iteration of the ignore-whitespace option for git-apply. Sorry for the long delay from the previous one, but I've been busy with real-life stuff. Significant changes since the previous iterations: * a boolean config option has been introduced * the patch that synchronized the whitespace when it was being ignored has been squashed in * the fuzzy buffer comparison needs the length of both buffers since, as pointed out in a private comunication, the hash check is not enough to guarantee that the candidates have the same non-whitespace characters With regard to this, by the way, the expected failure for patch3 is currently catched by a hashing, but it should be improved by generating two lines with the same hash, one being a proper initial substring of the other (modulo whitespace); a situation which I wasn't able to create without resorting to situations that would make git (and diff) go binary. Suggestions welcome. Also, I've come across the need to implement a similar option for merges (which basically reduces to adding the flag XDF_IGNORE_WHITESPACE_CHANGE in appropriate places) but couldn't come up with a sensible way to expose it via parameters to pass through to the merge engines, whose interactions are a little over my head for now. Documentation/config.txt | 5 + Documentation/git-am.txt | 3 +- Documentation/git-apply.txt | 7 ++ Documentation/git-rebase.txt | 3 +- builtin-apply.c | 135 ++++++++++++++++++++++++++++-- contrib/completion/git-completion.bash | 3 + git-am.sh | 3 +- git-rebase.sh | 3 + t/t4107-apply-ignore-whitespace.sh | 143 ++++++++++++++++++++++++++++++++ 9 files changed, 295 insertions(+), 10 deletions(-) create mode 100755 t/t4107-apply-ignore-whitespace.sh diff --git a/Documentation/config.txt b/Documentation/config.txt index 792dd42..c24fa5d 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -461,6 +461,11 @@ it will be treated as a shell command. For example, defining executed from the top-level directory of a repository, which may not necessarily be the current directory. +apply.ignore-whitespace:: + Tells 'git-apply' to ignore whitespaces differences, + in the same way as the '--ignore-whitespace' option. + See linkgit:git-apply[1]. + apply.whitespace:: Tells 'git-apply' how to handle whitespaces, in the same way as the '--whitespace' option. See linkgit:git-apply[1]. diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index 32e689b..acd2a5d 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -11,7 +11,7 @@ SYNOPSIS [verse] 'git am' [--signoff] [--keep] [--utf8 | --no-utf8] [--3way] [--interactive] [--committer-date-is-author-date] - [--ignore-date] + [--ignore-date] [--ignore-whitespace] [--whitespace=