git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: builtin conversion between tabs and spaces

From
Stefan Karpinski <stefan.karpinski@gmail.com>
Date
Oct 15, 2008, 20:52 UTC
Message-ID
<d4bc1a2a0810151352s6c963e32jc4f492a7c84841dc@mail.gmail.com>
In-Reply-To
<20081015062539.GB3775@blimp.localdomain>
> Is your conversion two-way? IOW, is it possible to convert the
> converted file and get the original? (Because all the existing
> conversions are reversible)

Yes and no. The CRLF conversion isn't always invertable—it is so long as your use of CRLF/LF is consistent. The tab/space conversion is similar: if you consistently use spaces, then tabs_to_spaces will always give you back your original version; if you consistently use tabs, then spaces_to_tabs will give you back your original version. If you use some crazy mix of the two, you cannot reconstruct your original without remembering where there were tabs versus spaces, which information either filter destroys. But that's the same as the CRLF conversion. You could enable a warning when worktree file has an inconsistent mixture of tabs and spaces, like there is for inconsistent CRLF files.

On Tue, Oct 14, 2008 at 11:25 PM, Alex Riesen <raa.lkml@gmail.com> wrote:
Show 17 quoted lines
> Stefan Karpinski, Wed, Oct 15, 2008 03:44:10 +0200:
>> I find myself really wanting to enforce standards in the use of spaces
>> versus tabs. I deal with some unruly programmers who refuse to set
>> their editors to use soft tabs, but I *hate* tabs in the repo. And of
>> course others feel equally strongly about keeping only tabs in the
>> repo (e.g. the git repo).
>>
>> This led me to wonder if it wouldn't make sense to have this
>> conversion ability built into git. The following patch implements this
>> functionality. It still needs work—it's not meant to be final, just to
>> give an idea—but I just wanted to see if people on the git list
>> thought this sort of thing would be worthwhile at all.
>
> Is your conversion two-way? IOW, is it possible to convert the
> converted file and get the original? (Because all the existing
> conversions are reversible)
>
Previous: Alex RiesenNext: Jonathan del Strother
Message 4 of 11 in “builtin conversion between tabs and spaces”
  1. Stefan KarpinskiOct 15, 2008
  2. Stefan KarpinskiOct 15, 2008
  3. Alex RiesenOct 15, 2008
  4. Stefan KarpinskiOct 15, 2008
  5. Jonathan del StrotherOct 15, 2008
  6. Stefan KarpinskiOct 15, 2008
  7. Stefan KarpinskiOct 15, 2008
  8. A Large Angry SCMOct 15, 2008
  9. Stefan KarpinskiOct 16, 2008
  10. Johannes SixtOct 15, 2008
  11. Stefan KarpinskiOct 15, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.