开发者

git svn windows linux whitespace problems

开发者 https://www.devze.com 2022-12-20 23:12 出处:网络
I use git (with git-svn) on linux and a colleague uses svn on windows. So many times, git reports whites开发者_如何学运维pace issues. In fact it fails to commit a linear history because of these prob

I use git (with git-svn) on linux and a colleague uses svn on windows.

So many times, git reports whites开发者_如何学运维pace issues. In fact it fails to commit a linear history because of these problems and creates merge conflicts.

What is the simplest way to configure svn/git and git-svn on windows and linux so that there are now whitespace issues?

Following is a reported merge conflict, in a linear history on master:

error: patch failed: frontend/templates/frontend/base.html:38
error: frontend/templates/frontend/base.html: patch does not apply
error: patch failed: frontend/templates/frontend/footer.html:1
error: frontend/templates/frontend/footer.html: patch does not apply
error: patch failed: frontend/templates/frontend/index.html:1
error: frontend/templates/frontend/index.html: patch does not apply
Using index info to reconstruct a base tree...
<stdin>:15: trailing whitespace.

<stdin>:20: trailing whitespace.
          <a href="{% url frontend_index %}">
<stdin>:22: trailing whitespace.
          </a>
<stdin>:24: trailing whitespace.
        <span class="companyname">
<stdin>:25: trailing whitespace.
          <a href="{% url frontend_index %}">
warning: squelched 74 whitespace errors
warning: 79 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging frontend/templates/frontend/base.html
CONFLICT (content): Merge conflict in frontend/templates/frontend/base.html
Auto-merging frontend/templates/frontend/index.html
CONFLICT (content): Merge conflict in frontend/templates/frontend/index.html
Failed to merge in the changes.
Patch failed at 0001 template changes

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

How do I solve the whitespace issues?


Fixing whitespace errors

Add this to .gitconfig

[core]
  whitespace=nowarn

git rebase should now work. (You can optionally add some of fix,-indent-with-non-tab,trailing-space to that to have git fix all whitespaces at every commit. Whether that is a good idea depends on your project rules and team. )

Fixing eol errors

[core]
  autocrlf = true

in your .gitconfig. This will force every text file to have windows line endings. svn by default ignores line endings and if your text editors on windows are sane you can leave it that way. Otherwise, add this file to your svn config (optionally changing native to CRLF) ensuring consistent CRLF line endings through out.

Set autocrlf = input and change native to LF for consistently linux line endings throughout.

0

精彩评论

暂无评论...
验证码 换一张
取 消