1

I am contributing code to an open source project which requires that no tabs exist in source code(only spaces). I am sure I have used tabs accidentally in some places, and want to clean up my code before I submit a patch. How can I find uses of tabs in a commit range?

Mike
  • 22,252
  • 18
  • 68
  • 88

1 Answers1

2

For commits you haven't pushed yet, you can use filter-branch:
See this SO question for a concrete example

git filter-branch --tree-filter '~/Scripts/fix-line-endings.sh' -- --all

(that is for all commits, you need to restrict it for a range of commit, see git filter-branch man page)

For future commits, use a filter driver

alt text

git config --global filter.tabspace.clean 'script_to_clean_tabs_at_eol'

Use the 'clean' step to cleanup tabs.

ax.
  • 56,201
  • 7
  • 77
  • 69
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755