From: Giuseppe Bilotta Date: Tue, 28 Jul 2009 21:00:20 GMT Subject: [PATCHv3] git apply: option to ignore whitespace differences Message-ID: <1248814820-25367-1-git-send-email-giuseppe.bilotta@gmail.com> 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=