3

I'm initially trying to adapt soft tabs in my projects but some testing with a python project tracked by git is showing issues; naturally git thinks everything has changed, and that is not what I'd prefer.

While git diff understands to drop whitespace from comparison with -w switch, there's no such switch for git commit.

Is the transition impossible to do nicely or is there a way to achieve git to ignore the sudden change?

mike3996
  • 17,047
  • 9
  • 64
  • 80
  • 2
    I don't understand. Do you want to commit the change from tabs to spaces or not? Why is it bad that "git thinks everything has changed"? If you've changed every line with a tab, then that may well be the case. – CB Bailey Jul 25 '10 at 09:42
  • Changing indentation doesn't bring anything to the code and therefore clutters comparing commits between pre- and post-change. – mike3996 Jul 25 '10 at 09:44
  • 3
    I still don't understand. If it doesn't bring anything to the code then don't change it. If your issue is purely about ignoring whitespace in the changes why not continue to use `-w` with diff (and show and log, etc.) ? – CB Bailey Jul 25 '10 at 09:46
  • My comments weren't thoughts, though, they were questions. Is your question purely about the display of diffs, or so you want to do something different like use soft tabs in your worktree but not commit the tab-to-space change when using commit which is what your original question implied? I genuinely still don't understand exactly what you are asking. – CB Bailey Jul 25 '10 at 09:56
  • Brought to us by [harshh](http://stackoverflow.com/users/63841/harshh) below, this is a possible duplicate of [Can git automatically switch between spaces and tabs?](http://stackoverflow.com/questions/2316677/can-git-automatically-switch-between-spaces-and-tabs) – P Shved Jul 25 '10 at 10:08
  • I was just looking for a frictionless option. Perhaps the `-w` does help with most of the actions. My aim was to have hard tabs converted to soft ones from that commit on, but to have easy access to old commits as well. But then the hard and soft tabs would mix up pretty ugly. I'll consider your rationing here the answer for my issue. – mike3996 Jul 25 '10 at 10:11

1 Answers1

4

Can git automatically switch between spaces and tabs?

Community
  • 1
  • 1
simplyharsh
  • 35,488
  • 12
  • 65
  • 73
  • 1
    It's a very good solution but I wouldn't be comfortable with having different contents in work dir and the repo – mike3996 Jul 25 '10 at 10:19