From mboxrd@z Thu Jan 1 00:00:00 1970 From: Giuseppe Bilotta Subject: [PATCHv4] git apply: option to ignore whitespace differences Date: Tue, 4 Aug 2009 13:16:49 +0200 Message-ID: <1249384609-30240-1-git-send-email-giuseppe.bilotta@gmail.com> Cc: Junio C Hamano , Felipe Contreras , Nanako Shiraishi , Giuseppe Bilotta To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Tue Aug 04 13:17:16 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 1MYI15-0007Sq-3C for gcvg-git-2@gmane.org; Tue, 04 Aug 2009 13:17:16 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752680AbZHDLRC (ORCPT ); Tue, 4 Aug 2009 07:17:02 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752490AbZHDLRB (ORCPT ); Tue, 4 Aug 2009 07:17:01 -0400 Received: from mail-bw0-f219.google.com ([209.85.218.219]:54108 "EHLO mail-bw0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751889AbZHDLQ7 (ORCPT ); Tue, 4 Aug 2009 07:16:59 -0400 Received: by bwz19 with SMTP id 19so3002709bwz.37 for ; Tue, 04 Aug 2009 04:16:58 -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=pjrUN752e+VIwJOXqJiAZRucwnAEZYToaigiDTSdpOs=; b=II0MvMogdsMBlNkufI8zYPvC4wn827YjJLzbx2/h3ZMNJlnrXszXUNqJnHNVrv9k2M 0hqtkiV2rex9SEBoN3YYQryTcFm0WLqLEPKup0oj930oUVWvh5uURa1edfEpa/yjf1Z8 werioBAumR3X5XWejryTg+yU42EsNG+RBH5as= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=TNEHJDLMIXlYyL0jBGQ3vHV4Ye5mD+jyzfshdbXoujdL5dtlaJAmc8unk42oPTTEyP uwx6F8xbGIyiYI0u1alpH5/STF3DVeAjR7Q6f9QDRrbuqmzW3jDNrXTX/SPx31+hjdHa ts2NCro4aj7fGMzl/T+yKQw0EkkJ7O1F/0VXI= Received: by 10.204.100.11 with SMTP id w11mr9886284bkn.32.1249384618806; Tue, 04 Aug 2009 04:16:58 -0700 (PDT) Received: from localhost (host-78-13-62-199.cust-adsl.tiscali.it [78.13.62.199]) by mx.google.com with ESMTPS id 18sm11873772fks.40.2009.08.04.04.16.56 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 04 Aug 2009 04:16:56 -0700 (PDT) X-Mailer: git-send-email 1.6.4.216.g15680.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 --- Following Junio's suggestion, the whitespace in the test has been replaced as appropriate with Z to prevent mangling on patch application. Some test cases have also been made more credible, and documentation has been added to all of them. Documentation/config.txt | 8 ++ Documentation/git-am.txt | 5 +- Documentation/git-apply.txt | 13 +++ Documentation/git-rebase.txt | 3 +- builtin-apply.c | 172 ++++++++++++++++++++++++++++++-- cache.h | 1 + contrib/completion/git-completion.bash | 3 + environment.c | 1 + git-am.sh | 4 +- git-rebase.sh | 3 + t/t4107-apply-ignore-whitespace.sh | 176 ++++++++++++++++++++++++++++++++ 11 files changed, 379 insertions(+), 10 deletions(-) create mode 100755 t/t4107-apply-ignore-whitespace.sh diff --git a/Documentation/config.txt b/Documentation/config.txt index c6f09f8..0b53cab 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -461,6 +461,14 @@ 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.ignorewhitespace:: + When set to 'change', tells 'git-apply' to ignore changes in + whitespace, in the same way as the '--ignore-space-change' + option. + When set to one of: no, none, never, false tells 'git-apply' to + respect all whitespace differences. + 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..fcacc94 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-space-change | --ignore-whitespace] [--whitespace=