[v2] btrfs-progs: Add basic .editorconfig
diff mbox series

Message ID 20200728015715.142747-1-dxu@dxuuu.xyz
State New
Headers show
Series
  • [v2] btrfs-progs: Add basic .editorconfig
Related show

Commit Message

Daniel Xu July 28, 2020, 1:57 a.m. UTC
Not all contributors work on projects that use linux kernel coding
style. This commit adds a basic editorconfig [0] to assist contributors
with managing configuration.

[0]: https://editorconfig.org/

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---
Changes from V1:
* use tabs instead of spaces

 .editorconfig | 10 ++++++++++
 .gitignore    |  1 +
 2 files changed, 11 insertions(+)
 create mode 100644 .editorconfig

--
2.27.0

Comments

Qu Wenruo July 28, 2020, 1:58 a.m. UTC | #1
On 2020/7/28 上午9:57, Daniel Xu wrote:
> Not all contributors work on projects that use linux kernel coding
> style. This commit adds a basic editorconfig [0] to assist contributors
> with managing configuration.
> 
> [0]: https://editorconfig.org/
> 
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> ---
> Changes from V1:
> * use tabs instead of spaces

That's fast! Just seconds before I exposed the indent_style problem.

Now it's properly reviewed.

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> 
>  .editorconfig | 10 ++++++++++
>  .gitignore    |  1 +
>  2 files changed, 11 insertions(+)
>  create mode 100644 .editorconfig
> 
> diff --git a/.editorconfig b/.editorconfig
> new file mode 100644
> index 00000000..7e15c503
> --- /dev/null
> +++ b/.editorconfig
> @@ -0,0 +1,10 @@
> +[*]
> +end_of_line = lf
> +insert_final_newline = true
> +trim_trailing_whitespace = true
> +charset = utf-8
> +indent_style = tab
> +indent_size = 8
> +
> +[*.py]
> +indent_size = 4
> diff --git a/.gitignore b/.gitignore
> index aadf9ae7..1c70ec94 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -65,6 +65,7 @@
>  /cscope.in.out
>  /cscope.po.out
>  .*
> +!.editorconfig
> 
>  /Documentation/Makefile
>  /Documentation/*.html
> --
> 2.27.0
>
Neal Gompa July 28, 2020, 2:23 a.m. UTC | #2
On Mon, Jul 27, 2020 at 9:58 PM Daniel Xu <dxu@dxuuu.xyz> wrote:
>
> Not all contributors work on projects that use linux kernel coding
> style. This commit adds a basic editorconfig [0] to assist contributors
> with managing configuration.
>
> [0]: https://editorconfig.org/
>
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> ---
> Changes from V1:
> * use tabs instead of spaces
>
>  .editorconfig | 10 ++++++++++
>  .gitignore    |  1 +
>  2 files changed, 11 insertions(+)
>  create mode 100644 .editorconfig
>
> diff --git a/.editorconfig b/.editorconfig
> new file mode 100644
> index 00000000..7e15c503
> --- /dev/null
> +++ b/.editorconfig
> @@ -0,0 +1,10 @@
> +[*]
> +end_of_line = lf
> +insert_final_newline = true
> +trim_trailing_whitespace = true
> +charset = utf-8
> +indent_style = tab
> +indent_size = 8
> +
> +[*.py]
> +indent_size = 4
> diff --git a/.gitignore b/.gitignore
> index aadf9ae7..1c70ec94 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -65,6 +65,7 @@
>  /cscope.in.out
>  /cscope.po.out
>  .*
> +!.editorconfig
>
>  /Documentation/Makefile
>  /Documentation/*.html
> --
> 2.27.0
>

LGTM.

Reviewed-by: Neal Gompa <ngompa13@gmail.com>
David Sterba July 28, 2020, 11:38 a.m. UTC | #3
On Mon, Jul 27, 2020 at 06:57:15PM -0700, Daniel Xu wrote:
> Not all contributors work on projects that use linux kernel coding
> style. This commit adds a basic editorconfig [0] to assist contributors
> with managing configuration.
> 
> [0]: https://editorconfig.org/
> 
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> ---
> Changes from V1:
> * use tabs instead of spaces
> 
>  .editorconfig | 10 ++++++++++
>  .gitignore    |  1 +
>  2 files changed, 11 insertions(+)
>  create mode 100644 .editorconfig
> 
> diff --git a/.editorconfig b/.editorconfig
> new file mode 100644
> index 00000000..7e15c503
> --- /dev/null
> +++ b/.editorconfig
> @@ -0,0 +1,10 @@
> +[*]
> +end_of_line = lf
> +insert_final_newline = true
> +trim_trailing_whitespace = true

Does this setting apply on lines that get changed or does it affect the
whole file? If it's just for the lines, then it's what we want.
Qu Wenruo July 28, 2020, 12:03 p.m. UTC | #4
On 2020/7/28 下午7:38, David Sterba wrote:
> On Mon, Jul 27, 2020 at 06:57:15PM -0700, Daniel Xu wrote:
>> Not all contributors work on projects that use linux kernel coding
>> style. This commit adds a basic editorconfig [0] to assist contributors
>> with managing configuration.
>>
>> [0]: https://editorconfig.org/
>>
>> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
>> ---
>> Changes from V1:
>> * use tabs instead of spaces
>>
>>  .editorconfig | 10 ++++++++++
>>  .gitignore    |  1 +
>>  2 files changed, 11 insertions(+)
>>  create mode 100644 .editorconfig
>>
>> diff --git a/.editorconfig b/.editorconfig
>> new file mode 100644
>> index 00000000..7e15c503
>> --- /dev/null
>> +++ b/.editorconfig
>> @@ -0,0 +1,10 @@
>> +[*]
>> +end_of_line = lf
>> +insert_final_newline = true
>> +trim_trailing_whitespace = true
> 
> Does this setting apply on lines that get changed or does it affect the
> whole file? If it's just for the lines, then it's what we want.
> 
At least from the vim plugin code, it's just for the new lines:

https://github.com/editorconfig/editorconfig-vim/blob/0a3c1d8082e38a5ebadcba7bb3a608d88a9ff044/plugin/editorconfig.vim#L494

It just call the replace on the current line.

Thanks,
Qu
Qu Wenruo July 28, 2020, 12:12 p.m. UTC | #5
On 2020/7/28 下午8:03, Qu Wenruo wrote:
> 
> 
> On 2020/7/28 下午7:38, David Sterba wrote:
>> On Mon, Jul 27, 2020 at 06:57:15PM -0700, Daniel Xu wrote:
>>> Not all contributors work on projects that use linux kernel coding
>>> style. This commit adds a basic editorconfig [0] to assist contributors
>>> with managing configuration.
>>>
>>> [0]: https://editorconfig.org/
>>>
>>> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
>>> ---
>>> Changes from V1:
>>> * use tabs instead of spaces
>>>
>>>  .editorconfig | 10 ++++++++++
>>>  .gitignore    |  1 +
>>>  2 files changed, 11 insertions(+)
>>>  create mode 100644 .editorconfig
>>>
>>> diff --git a/.editorconfig b/.editorconfig
>>> new file mode 100644
>>> index 00000000..7e15c503
>>> --- /dev/null
>>> +++ b/.editorconfig
>>> @@ -0,0 +1,10 @@
>>> +[*]
>>> +end_of_line = lf
>>> +insert_final_newline = true
>>> +trim_trailing_whitespace = true
>>
>> Does this setting apply on lines that get changed or does it affect the
>> whole file? If it's just for the lines, then it's what we want.
>>
> At least from the vim plugin code, it's just for the new lines:
> 
> https://github.com/editorconfig/editorconfig-vim/blob/0a3c1d8082e38a5ebadcba7bb3a608d88a9ff044/plugin/editorconfig.vim#L494
> 
> It just call the replace on the current line.

My bad, %s, it replaces all existing lines...

> 
> Thanks,
> Qu
>
David Sterba July 28, 2020, 12:57 p.m. UTC | #6
On Tue, Jul 28, 2020 at 08:12:40PM +0800, Qu Wenruo wrote:
> >>> +trim_trailing_whitespace = true
> >>
> >> Does this setting apply on lines that get changed or does it affect the
> >> whole file? If it's just for the lines, then it's what we want.
> >>
> > At least from the vim plugin code, it's just for the new lines:
> > 
> > https://github.com/editorconfig/editorconfig-vim/blob/0a3c1d8082e38a5ebadcba7bb3a608d88a9ff044/plugin/editorconfig.vim#L494
> > 
> > It just call the replace on the current line.
> 
> My bad, %s, it replaces all existing lines...

So this would introduce unrelated changes, but it seems that we don't
have much trailing whitespaces in progs codebase:

  $ git grep '\s\+$'
  btrfs-fragments.c:
  btrfs-fragments.c:                              black = gdImageColorAllocate(im, 0, 0, 0);  
  crypto/crc32c.c:/* 
  crypto/crc32c.c: * 
  crypto/crc32c.c: * Software Foundation; either version 2 of the License, or (at your option) 
  crypto/crc32c.c: * Steps through buffer one byte at at time, calculates reflected 
  crypto/crc32c.c: * Steps through buffer one byte at at time, calculates reflected 
  kernel-lib/radix-tree.h: * 
  kernel-lib/radix-tree.h: * 
  kernel-lib/rbtree.c:            node = node->rb_right; 
  kernel-lib/rbtree.c:            node = node->rb_left; 
  kernel-lib/rbtree.h:  

filtering only the sources. So let's keep it in the config.
Qu Wenruo July 28, 2020, 1 p.m. UTC | #7
On 2020/7/28 下午8:57, David Sterba wrote:
> On Tue, Jul 28, 2020 at 08:12:40PM +0800, Qu Wenruo wrote:
>>>>> +trim_trailing_whitespace = true
>>>>
>>>> Does this setting apply on lines that get changed or does it affect the
>>>> whole file? If it's just for the lines, then it's what we want.
>>>>
>>> At least from the vim plugin code, it's just for the new lines:
>>>
>>> https://github.com/editorconfig/editorconfig-vim/blob/0a3c1d8082e38a5ebadcba7bb3a608d88a9ff044/plugin/editorconfig.vim#L494
>>>
>>> It just call the replace on the current line.
>>
>> My bad, %s, it replaces all existing lines...
> 
> So this would introduce unrelated changes, but it seems that we don't
> have much trailing whitespaces in progs codebase:
> 
>   $ git grep '\s\+$'
>   btrfs-fragments.c:
>   btrfs-fragments.c:                              black = gdImageColorAllocate(im, 0, 0, 0);  
>   crypto/crc32c.c:/* 
>   crypto/crc32c.c: * 
>   crypto/crc32c.c: * Software Foundation; either version 2 of the License, or (at your option) 
>   crypto/crc32c.c: * Steps through buffer one byte at at time, calculates reflected 
>   crypto/crc32c.c: * Steps through buffer one byte at at time, calculates reflected 
>   kernel-lib/radix-tree.h: * 
>   kernel-lib/radix-tree.h: * 
>   kernel-lib/rbtree.c:            node = node->rb_right; 
>   kernel-lib/rbtree.c:            node = node->rb_left; 
>   kernel-lib/rbtree.h:  
> 
> filtering only the sources. So let's keep it in the config.
> 
Great.

BTW, it would be better to mention we use editorconfig as the unified
formatting config.

As most of us are using vim, which doesn't support editorconfig by
default, thus we need to install that plugin manually.

Thanks,
Qu
Daniel Xu July 28, 2020, 5:24 p.m. UTC | #8
On Tue Jul 28, 2020 at 5:57 AM PDT, David Sterba wrote:
> On Tue, Jul 28, 2020 at 08:12:40PM +0800, Qu Wenruo wrote:
> > >>> +trim_trailing_whitespace = true
> > >>
> > >> Does this setting apply on lines that get changed or does it affect the
> > >> whole file? If it's just for the lines, then it's what we want.
> > >>
> > > At least from the vim plugin code, it's just for the new lines:
> > > 
> > > https://github.com/editorconfig/editorconfig-vim/blob/0a3c1d8082e38a5ebadcba7bb3a608d88a9ff044/plugin/editorconfig.vim#L494
> > > 
> > > It just call the replace on the current line.
> > 
> > My bad, %s, it replaces all existing lines...
>
> So this would introduce unrelated changes, but it seems that we don't
> have much trailing whitespaces in progs codebase:
>
> $ git grep '\s\+$'
> btrfs-fragments.c:
> btrfs-fragments.c: black = gdImageColorAllocate(im, 0, 0, 0);
> crypto/crc32c.c:/*
> crypto/crc32c.c: *
> crypto/crc32c.c: * Software Foundation; either version 2 of the License,
> or (at your option)
> crypto/crc32c.c: * Steps through buffer one byte at at time, calculates
> reflected
> crypto/crc32c.c: * Steps through buffer one byte at at time, calculates
> reflected
> kernel-lib/radix-tree.h: *
> kernel-lib/radix-tree.h: *
> kernel-lib/rbtree.c: node = node->rb_right;
> kernel-lib/rbtree.c: node = node->rb_left;
> kernel-lib/rbtree.h:
>
> filtering only the sources. So let's keep it in the config.

Sounds good. Should I send a followup patch to delete the existing
trailing lines?
Daniel Xu July 28, 2020, 5:26 p.m. UTC | #9
On Tue Jul 28, 2020 at 6:00 AM PDT, Qu Wenruo wrote:
>
>
> On 2020/7/28 下午8:57, David Sterba wrote:
> > On Tue, Jul 28, 2020 at 08:12:40PM +0800, Qu Wenruo wrote:
> >>>>> +trim_trailing_whitespace = true
> >>>>
> >>>> Does this setting apply on lines that get changed or does it affect the
> >>>> whole file? If it's just for the lines, then it's what we want.
> >>>>
> >>> At least from the vim plugin code, it's just for the new lines:
> >>>
> >>> https://github.com/editorconfig/editorconfig-vim/blob/0a3c1d8082e38a5ebadcba7bb3a608d88a9ff044/plugin/editorconfig.vim#L494
> >>>
> >>> It just call the replace on the current line.
> >>
> >> My bad, %s, it replaces all existing lines...
> > 
> > So this would introduce unrelated changes, but it seems that we don't
> > have much trailing whitespaces in progs codebase:
> > 
> >   $ git grep '\s\+$'
> >   btrfs-fragments.c:
> >   btrfs-fragments.c:                              black = gdImageColorAllocate(im, 0, 0, 0);  
> >   crypto/crc32c.c:/* 
> >   crypto/crc32c.c: * 
> >   crypto/crc32c.c: * Software Foundation; either version 2 of the License, or (at your option) 
> >   crypto/crc32c.c: * Steps through buffer one byte at at time, calculates reflected 
> >   crypto/crc32c.c: * Steps through buffer one byte at at time, calculates reflected 
> >   kernel-lib/radix-tree.h: * 
> >   kernel-lib/radix-tree.h: * 
> >   kernel-lib/rbtree.c:            node = node->rb_right; 
> >   kernel-lib/rbtree.c:            node = node->rb_left; 
> >   kernel-lib/rbtree.h:  
> > 
> > filtering only the sources. So let's keep it in the config.
> > 
> Great.
>
> BTW, it would be better to mention we use editorconfig as the unified
> formatting config.
>
> As most of us are using vim, which doesn't support editorconfig by
> default, thus we need to install that plugin manually.

Sure, should a hint about editorconfig go into the `Development` section
of the README.md?
David Sterba July 29, 2020, 9:58 a.m. UTC | #10
On Tue, Jul 28, 2020 at 10:24:31AM -0700, Daniel Xu wrote:
> On Tue Jul 28, 2020 at 5:57 AM PDT, David Sterba wrote:
> > On Tue, Jul 28, 2020 at 08:12:40PM +0800, Qu Wenruo wrote:
> > > >>> +trim_trailing_whitespace = true
> > > >>
> > > >> Does this setting apply on lines that get changed or does it affect the
> > > >> whole file? If it's just for the lines, then it's what we want.
> > > >>
> > > > At least from the vim plugin code, it's just for the new lines:
> > > > 
> > > > https://github.com/editorconfig/editorconfig-vim/blob/0a3c1d8082e38a5ebadcba7bb3a608d88a9ff044/plugin/editorconfig.vim#L494
> > > > 
> > > > It just call the replace on the current line.
> > > 
> > > My bad, %s, it replaces all existing lines...
> >
> > So this would introduce unrelated changes, but it seems that we don't
> > have much trailing whitespaces in progs codebase:
> >
> > $ git grep '\s\+$'
> > btrfs-fragments.c:
> > btrfs-fragments.c: black = gdImageColorAllocate(im, 0, 0, 0);
> > crypto/crc32c.c:/*
> > crypto/crc32c.c: *
> > crypto/crc32c.c: * Software Foundation; either version 2 of the License,
> > or (at your option)
> > crypto/crc32c.c: * Steps through buffer one byte at at time, calculates
> > reflected
> > crypto/crc32c.c: * Steps through buffer one byte at at time, calculates
> > reflected
> > kernel-lib/radix-tree.h: *
> > kernel-lib/radix-tree.h: *
> > kernel-lib/rbtree.c: node = node->rb_right;
> > kernel-lib/rbtree.c: node = node->rb_left;
> > kernel-lib/rbtree.h:
> >
> > filtering only the sources. So let's keep it in the config.
> 
> Sounds good. Should I send a followup patch to delete the existing
> trailing lines?

That's all in files that are synced from kernel and we won't need to
edit them anyway.
David Sterba July 29, 2020, 9:59 a.m. UTC | #11
On Tue, Jul 28, 2020 at 10:26:58AM -0700, Daniel Xu wrote:
> On Tue Jul 28, 2020 at 6:00 AM PDT, Qu Wenruo wrote:
> >
> >
> > On 2020/7/28 下午8:57, David Sterba wrote:
> > > On Tue, Jul 28, 2020 at 08:12:40PM +0800, Qu Wenruo wrote:
> > >>>>> +trim_trailing_whitespace = true
> > >>>>
> > >>>> Does this setting apply on lines that get changed or does it affect the
> > >>>> whole file? If it's just for the lines, then it's what we want.
> > >>>>
> > >>> At least from the vim plugin code, it's just for the new lines:
> > >>>
> > >>> https://github.com/editorconfig/editorconfig-vim/blob/0a3c1d8082e38a5ebadcba7bb3a608d88a9ff044/plugin/editorconfig.vim#L494
> > >>>
> > >>> It just call the replace on the current line.
> > >>
> > >> My bad, %s, it replaces all existing lines...
> > > 
> > > So this would introduce unrelated changes, but it seems that we don't
> > > have much trailing whitespaces in progs codebase:
> > > 
> > >   $ git grep '\s\+$'
> > >   btrfs-fragments.c:
> > >   btrfs-fragments.c:                              black = gdImageColorAllocate(im, 0, 0, 0);  
> > >   crypto/crc32c.c:/* 
> > >   crypto/crc32c.c: * 
> > >   crypto/crc32c.c: * Software Foundation; either version 2 of the License, or (at your option) 
> > >   crypto/crc32c.c: * Steps through buffer one byte at at time, calculates reflected 
> > >   crypto/crc32c.c: * Steps through buffer one byte at at time, calculates reflected 
> > >   kernel-lib/radix-tree.h: * 
> > >   kernel-lib/radix-tree.h: * 
> > >   kernel-lib/rbtree.c:            node = node->rb_right; 
> > >   kernel-lib/rbtree.c:            node = node->rb_left; 
> > >   kernel-lib/rbtree.h:  
> > > 
> > > filtering only the sources. So let's keep it in the config.
> > > 
> > Great.
> >
> > BTW, it would be better to mention we use editorconfig as the unified
> > formatting config.
> >
> > As most of us are using vim, which doesn't support editorconfig by
> > default, thus we need to install that plugin manually.
> 
> Sure, should a hint about editorconfig go into the `Development` section
> of the README.md?

Yeah that would be useful, thanks.

Patch
diff mbox series

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..7e15c503
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,10 @@ 
+[*]
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+charset = utf-8
+indent_style = tab
+indent_size = 8
+
+[*.py]
+indent_size = 4
diff --git a/.gitignore b/.gitignore
index aadf9ae7..1c70ec94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,6 +65,7 @@ 
 /cscope.in.out
 /cscope.po.out
 .*
+!.editorconfig

 /Documentation/Makefile
 /Documentation/*.html