Re: Fw: Tabs vs Spaces - Handle like CLRF?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 19, 2021 at 03:55:46PM +0000, James Hughes wrote:

> We have the ability to automagically handle CLRF issues when we commit
> and check-out to handle different dev environments.
> 
> A lot of us will also hold religious beliefs as to which is the
> correct way to indent, tabs or spaces.
> 
> Since it's simple a whitespacing issue, is there any reason we
> couldn't handle this in a similar way to CLRF? Give devs the choice to
> commit with tabs/spaces as per their organisations requirements and
> then convert to their preference on checkout?

You can. See clean/smudge filters in the gitattributes(5) manpage. You'd
declare one of them the canonical in-repo format (let's say tabs). Then
your "clean" filter would convert spaces-to-tabs, perhaps with something
like "perl -pe 's/ {8}/\t/g'". And your "smudge" filter would convert
tabs back to spaces.

And then you just mark the files you want converted with an attribute in
.gitattributes, and wire up that attribute to the filters in your
config.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux