-
8000
Notifications
You must be signed in to change notification settings - Fork 239
Tabs to whitespaces #1201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tabs to whitespaces #1201
Conversation
👍 |
⏩ |
I must admit, the proposed plan is not quite working on non-simplistic branches. |
More (computationally) expensive, but working for me plan. (A, M, T branches as above)
Questions and improvements are welcome. |
Tom has reported a successful result using the second approach for the updating of the branches. |
OpenGeoSys development has been moved to GitLab. |
As discussed about one week ago here is a PR changing tabs to 4 whitespaces almost everywhere. The configs are updated too; add
?ws=1
to the address line when viewing the diff like here: diff ignoring whitespace changes.Almost all of your branches will have merge/rebase conflicts. To resolve those as painless as possible there is a small script and some command with explanation, but before you make any changes make a backup. Like real backup, not a shallow clone, because if you destroy you .git/* the behaviour is undefined. Don't ask me how I know.
Plan (which didn't work like expected. See another plan in the comments.):
for any branch:
git filter-branch
You will need a small script named
t2ws.sh
from this gistLet's assume you have a branch A somewhere. The current master is M. The merged TabsToWhitespaces PR is T:
git rebase M A
(this is your usual business). The new branch is called A':git filter-branch -f --tree-filter "git diff --name-only --diff-filter=AM ${GIT_COMMIT}^ | xargs t2ws.sh" M..A'
Let's call the rewritten history of A' as A'':git rebase -Xignore-all-space T A''
yields the following graph ignoring the whitespace changes:The filter-branch works like this: the --tree-filter checks out every commit (specified by the range M..A above) and runs a given command. The
git diff --name-only --diff-filter=AM ${GIT_COMMIT}^
print file names which were added/modified since previous commit, the${GIT_COMMIT}^
. (Try it at any of your branches to see the output. The command is harmless.) This files are then processed by the script, which ignores empty input and non-regular-file input (like directories e.g.Tests/Data
). Then filter-branch's tree-filter makes a new commit and goes to the next one.Don't forget to backup!
Addendum: Sometimes (when skipping the first step for example), after the step 3 there could be new tabs in the code. One can check for this with
git diff --name-only --diff-filter=AM ufz/master | xargs grep '\t'
or something like this.