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
  • 23,892
  • 18
  • 70
  • 90

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.
  • 58,560
  • 8
  • 81
  • 72
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250