Git p4 submit: patch not applicable

Recently, I have run into problems using git -p4.

My current workflow:

git checkout -b some_feature
# do some work and commit to some_feature branch
git checkout master
git merge --no-ff some_feature
git p4 rebase
git p4 submit

Not always, but sometimes during execution, the git p4 submitchanges are not actually applied, and instead I see:

error: some_file.extension: patch does not apply

After doing some research, I tried to do a hard reset on the main server and merge again without a flag --no-ff, but this does not seem to help.

Any ideas are welcome.

+5
source share
2 answers

. , (Visual Studio) Unicode BOM , . Perforce Unicode , Unicode Perforce. git p4 submit :

error: patch failed: path/to/file.csproj:1
error: path/to/file.csproj: patch does not apply

~/.gitconfig:

[filter "utf8-autobom"]
        clean = sed -b -e '1!b' -e 's/^\\xEF\\xBB\\xBF//'
        smudge = sed -b -e '1!b' -e 's/\\(^\\|^\\xEF\\xBB\\xBF\\)/\\xEF\\xBB\\xBF/'

utf8-autobom , .gitattributes:

*.csproj filter=utf8-autobom

Git :

rm .git/index
git reset

Git Perforce, :

git add .
git commit --amend
git p4 submit

sed, "abc" :

# Remove 'abc' from beginning of file, if present
sed -b -e '1!b' -e 's/^abc//'

# Add 'abc' to beginning of file, if not present
sed -b -e '1!b' -e 's/\(^\|^abc\)/abc/'

UTF-8 EF BB BF "abc".

, clean , smudge. , , Git Perforce.

( clean smudge . gitattributes)

, :

error: patch failed: path/to/file.csproj:1
error: path/to/file.csproj: patch does not apply

, 1, 1 .

, , git diff p4/master HEAD. , <U+FEFF> . , , Notepad ++, Git. Perforce. Notepad ++ "UTF-8-BOM" Git "UTF-8" Perforce. ( Linux Cygwin: file <path-to-file>, .)

Googling "UTF-8-BOM" .

Git .

smudge, . Git (, git checkout). smudge :

[filter "utf8-autobom"]
        clean = sed -b -e '1!b' -e 's/^\\xEF\\xBB\\xBF//'
+6

, , . dos2unix, , :

git config --global core.autocrlf true

. ( ):

git config core.filemode false
+4

All Articles