2017-01-16 123 views
1

白色空间相关的变化。为了保证只非空格相关的变化,我试着这样做:不能忽略的Git

git diff -w --no-color | git apply --cached --ignore-whitespace 

但我收到此错误:

<stdin>:12: indent with spaces. 
     if (! $data['first_name'] && ! $data['last_name']) { 
<stdin>:13: indent with spaces. 
      $data['first_name'] = NULL; 
<stdin>:14: indent with spaces. 
      $data['last_name'] = NULL; 
<stdin>:15: indent with spaces. 
     } 
error: patch failed: application/libraries/api_data.php:89 
error: application/libraries/api_data.php: patch does not apply 

我还设置autocrlffalse这样的:

git config --global core.autocrlf false 

然而,与git diff我看到整个文件被改变,而不是我添加的行。

也是我的git config -l输出:

core.excludesfile=~/.gitignore 
core.legacyheaders=false 
core.quotepath=false 
core.pager=less 
mergetool.keepbackup=true 
push.default=simple 
color.ui=auto 
color.interactive=auto 
repack.usedeltabaseoffset=true 
alias.s=status 
alias.a=!git add . && git status 
alias.au=!git add -u . && git status 
alias.aa=!git add . && git add -u . && git status 
alias.c=commit 
alias.cm=commit -m 
alias.ca=commit --amend 
alias.ac=!git add . && git commit 
alias.acm=!git add . && git commit -m 
alias.l=log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset' 
alias.ll=log --stat --abbrev-commit 
alias.lg=log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative 
alias.llg=log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit 
alias.d=diff 
alias.master=checkout master 
alias.spull=svn rebase 
alias.spush=svn dcommit 
alias.alias=!git config --list | grep 'alias\.' | sed 's/alias\.\([^=]*\)=\(.*\)/\1\  => \2/' | sort 
include.path=~/.gitcinclude 
include.path=.githubconfig 
include.path=.gitcredential 
diff.exif.textconv=exif 
credential.helper=osxkeychain 
core.excludesfile=/Users/ankurk/.gitignore_global 
core.autocrlf=false 
core.whitespace=trailing-space,space-before-tab,indent-with-non-tab 
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE" 
difftool.sourcetree.path= 
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED" 
mergetool.sourcetree.trustexitcode=true 
user.name= 
user.email= 
commit.template=/Users/ankurk/.stCommitMsg 
core.repositoryformatversion=0 
core.filemode=true 
core.bare=false 
core.logallrefupdates=true 
core.ignorecase=true 
core.precomposeunicode=true 
core.autocrlf=false 
remote.origin.url= 
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* 
branch.master.remote=origin 
branch.master.merge=refs/heads/master 
branch.feature_add-eds-brand-name-marketers.remote=origin 
branch.feature_add-eds-brand-name-marketers.merge=refs/heads/feature_repo 

我能做些什么来解决这个问题?

+0

你能分享你的“git config -l”输出吗? – jbu

+0

考虑删除您的编辑中的个人数据...我也发布了一个可能的答案 – jbu

回答

0

看完My diff contains trailing whitespace - how to get rid of it?后,看着你的输出,我不确定这些是由于空白造成的错误。我认为这些是警告。

我认为真正的错误是行89:

error: patch failed: application/libraries/api_data.php:89 error: application/libraries/api_data.php: patch does not apply

什么是线89呢?

+0

89行只是一个功能的右大括号。 – thedeliciousmuffin

+0

考虑使用git apply和--whitespace = nowarn来验证这些是错误还是警告。 关于大括号,是否有任何理由不能应用? – jbu

+0

仍然补丁失败。 :/ – thedeliciousmuffin