git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fw: Tabs vs Spaces - Handle like CLRF?
       [not found] <2AzjQ7QDayLsqCbYQzwoZhJvvWKVAlBXStsOtYN03i41hVJcbYou0Je8Sxqec8UB0j0ZAfhKosA_IymlTez2X1J-voxUfG65EA-Zm0YWU10=@pyrosoftsolutions.co.uk>
@ 2021-05-19 15:55 ` James Hughes
  2021-05-19 16:28   ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: James Hughes @ 2021-05-19 15:55 UTC (permalink / raw)
  To: git

Hi all,

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?

All the best,

James


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fw: Tabs vs Spaces - Handle like CLRF?
  2021-05-19 15:55 ` Fw: Tabs vs Spaces - Handle like CLRF? James Hughes
@ 2021-05-19 16:28   ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2021-05-19 16:28 UTC (permalink / raw)
  To: James Hughes; +Cc: git

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-19 16:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <2AzjQ7QDayLsqCbYQzwoZhJvvWKVAlBXStsOtYN03i41hVJcbYou0Je8Sxqec8UB0j0ZAfhKosA_IymlTez2X1J-voxUfG65EA-Zm0YWU10=@pyrosoftsolutions.co.uk>
2021-05-19 15:55 ` Fw: Tabs vs Spaces - Handle like CLRF? James Hughes
2021-05-19 16:28   ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).