diff mbox

Added info on removing trailing whitespace

Message ID 1405029940-8967-1-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit 8e03663cb66cae7b1f4b0aa6e36f25c261c68d2d
Headers show

Commit Message

Bill Fischofer July 10, 2014, 10:05 p.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 CONTRIBUTING | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

vkamensky July 11, 2014, 3:37 a.m. UTC | #1
BTW the following config in my ~/.gitconfig

[core]
        whitespace = trailing-space,space-before-tab,indent-with-non-tab

allows me to see white space issues when I run git diff. It shows
questionable places in red.

Normally wrt white spaces if git diff is happy checkpatch.pl will be happy
as well.

Thanks,
Victor

On 10 July 2014 15:05, Bill Fischofer <bill.fischofer@linaro.org> wrote:
> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
>  CONTRIBUTING | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/CONTRIBUTING b/CONTRIBUTING
> index 0508a9f..37330ca 100644
> --- a/CONTRIBUTING
> +++ b/CONTRIBUTING
> @@ -34,6 +34,19 @@ compiler:
>
>         ./scripts/checkpatch.pl file.patch
>
> +    Note: A common issue that causes patches to fail checkpatch is the
> +    presense of trailing whitespace.  Emacs users can use the command:
> +
> +    Meta-X delete-trailing-whitespace
> +
> +    to scrub the file prior to saving to avoid these issues.  Vim users
> +    can accomplish the same with the command:
> +
> +    :%s/\s\+$//
> +
> +    Please ensure submitted patches are checkpatch clean before submitting
> +    them to avoid having them automatically returned for rework.
> +
>  [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle
>  [2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches
>  [3] refer to README file.
> --
> 1.8.3.2
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Maxim Uvarov July 11, 2014, 10:29 a.m. UTC | #2
On 07/11/2014 07:37 AM, Victor Kamensky wrote:
> BTW the following config in my ~/.gitconfig
>
> [core]
>          whitespace = trailing-space,space-before-tab,indent-with-non-tab
>
> allows me to see white space issues when I run git diff. It shows
> questionable places in red.
Thanks that is cool. I'm also attaching my .vimrc which I copied from 
some sourceforge page (was something like vim whitespace).

In ODP we also have:
./scripts/cleanfile
# Clean a text file -- or directory of text files -- of stealth whitespace.
# WARNING: this can be a highly destructive operation.  Use with caution.
#

Thanks,
Maxim.

> Normally wrt white spaces if git diff is happy checkpatch.pl will be happy
> as well.
>
> Thanks,
> Victor
>
> On 10 July 2014 15:05, Bill Fischofer <bill.fischofer@linaro.org> wrote:
>> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
>> ---
>>   CONTRIBUTING | 13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>
>> diff --git a/CONTRIBUTING b/CONTRIBUTING
>> index 0508a9f..37330ca 100644
>> --- a/CONTRIBUTING
>> +++ b/CONTRIBUTING
>> @@ -34,6 +34,19 @@ compiler:
>>
>>          ./scripts/checkpatch.pl file.patch
>>
>> +    Note: A common issue that causes patches to fail checkpatch is the
>> +    presense of trailing whitespace.  Emacs users can use the command:
>> +
>> +    Meta-X delete-trailing-whitespace
>> +
>> +    to scrub the file prior to saving to avoid these issues.  Vim users
>> +    can accomplish the same with the command:
>> +
>> +    :%s/\s\+$//
>> +
>> +    Please ensure submitted patches are checkpatch clean before submitting
>> +    them to avoid having them automatically returned for rework.
>> +
>>   [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle
>>   [2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches
>>   [3] refer to README file.
>> --
>> 1.8.3.2
>>
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
" bad-whitespace.vim - Highlights whitespace at the end of lines
" Maintainer:   Bit Connor <bit@mutantlemon.com>
" Version:      0.3

function! s:ShowBadWhitespace(force)
  if a:force
    let b:bad_whitespace_show = 1
  endif
  highlight default BadWhitespace ctermbg=red guibg=red
  autocmd ColorScheme <buffer> highlight default BadWhitespace ctermbg=red guibg=red
  match BadWhitespace /\s\+$/
  autocmd InsertLeave <buffer> match BadWhitespace /\s\+$/
  autocmd InsertEnter <buffer> match BadWhitespace /\s\+\%#\@<!$/
endfunction

function! s:HideBadWhitespace(force)
  if a:force
    let b:bad_whitespace_show = 0
  endif
  match none BadWhitespace
endfunction

function! s:EnableShowBadWhitespace()
  if exists("b:bad_whitespace_show")
    return
  endif
  if &modifiable
    call <SID>ShowBadWhitespace(0)
  else
    call <SID>HideBadWhitespace(0)
  endif
endfunction

function! s:ToggleBadWhitespace()
  if !exists("b:bad_whitespace_show")
    let b:bad_whitespace_show = 0
    if &modifiable
      let b:bad_whitespace_show = 1
    endif
  endif
  if b:bad_whitespace_show
    call <SID>HideBadWhitespace(1)
  else
    call <SID>ShowBadWhitespace(1)
  endif
endfunction

autocmd BufWinEnter,WinEnter,FileType * call <SID>EnableShowBadWhitespace()

function! s:EraseBadWhitespace(line1,line2)
  let l:save_cursor = getpos(".")
  silent! execute ':' . a:line1 . ',' . a:line2 . 's/\s\+$//'
  call setpos('.', l:save_cursor)
endfunction

" Run :EraseBadWhitespace to remove end of line white space.
command! -range=% EraseBadWhitespace call <SID>EraseBadWhitespace(<line1>,<line2>)
command! ShowBadWhitespace call <SID>ShowBadWhitespace(1)
command! HideBadWhitespace call <SID>HideBadWhitespace(1)
command! ToggleBadWhitespace call <SID>ToggleBadWhitespace()
Maxim Uvarov July 11, 2014, 1:45 p.m. UTC | #3
Applied!

thanks,
Maxim.

On 07/11/2014 02:05 AM, Bill Fischofer wrote:
> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
>   CONTRIBUTING | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/CONTRIBUTING b/CONTRIBUTING
> index 0508a9f..37330ca 100644
> --- a/CONTRIBUTING
> +++ b/CONTRIBUTING
> @@ -34,6 +34,19 @@ compiler:
>   
>   	./scripts/checkpatch.pl file.patch
>   
> +    Note: A common issue that causes patches to fail checkpatch is the
> +    presense of trailing whitespace.  Emacs users can use the command:
> +
> +    Meta-X delete-trailing-whitespace
> +
> +    to scrub the file prior to saving to avoid these issues.  Vim users
> +    can accomplish the same with the command:
> +
> +    :%s/\s\+$//
> +
> +    Please ensure submitted patches are checkpatch clean before submitting
> +    them to avoid having them automatically returned for rework.
> +
>   [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle
>   [2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches
>   [3] refer to README file.
diff mbox

Patch

diff --git a/CONTRIBUTING b/CONTRIBUTING
index 0508a9f..37330ca 100644
--- a/CONTRIBUTING
+++ b/CONTRIBUTING
@@ -34,6 +34,19 @@  compiler:
 
 	./scripts/checkpatch.pl file.patch
 
+    Note: A common issue that causes patches to fail checkpatch is the
+    presense of trailing whitespace.  Emacs users can use the command:
+
+    Meta-X delete-trailing-whitespace
+
+    to scrub the file prior to saving to avoid these issues.  Vim users
+    can accomplish the same with the command:
+
+    :%s/\s\+$//
+
+    Please ensure submitted patches are checkpatch clean before submitting
+    them to avoid having them automatically returned for rework.
+
 [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle
 [2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches
 [3] refer to README file.