git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: James Hughes <james@pyrosoftsolutions.co.uk>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Fw: Tabs vs Spaces - Handle like CLRF?
Date: Wed, 19 May 2021 12:28:56 -0400	[thread overview]
Message-ID: <YKU8yMIO8uSuIYZh@coredump.intra.peff.net> (raw)
In-Reply-To: <GJHGZLcAwaihWwWmzAt8bdOKWi8JiupQxVUXCs1FwKTOmn2yvWEjI8DDTmDaBA48lzz4pGQ-JmwmHKSrEU2NCpdyxXW-ExqZcgxKEmL-454=@pyrosoftsolutions.co.uk>

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

      reply	other threads:[~2021-05-19 16:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2AzjQ7QDayLsqCbYQzwoZhJvvWKVAlBXStsOtYN03i41hVJcbYou0Je8Sxqec8UB0j0ZAfhKosA_IymlTez2X1J-voxUfG65EA-Zm0YWU10=@pyrosoftsolutions.co.uk>
2021-05-19 15:55 ` James Hughes
2021-05-19 16:28   ` Jeff King [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YKU8yMIO8uSuIYZh@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=james@pyrosoftsolutions.co.uk \
    --subject='Re: Fw: Tabs vs Spaces - Handle like CLRF?' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).