Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
[#719] Made the Git merge placeholder more unique (seven hashes could…
Browse files Browse the repository at this point in the history
… be used in some post quite easily)
  • Loading branch information
borekb committed Mar 3, 2016
1 parent 7820f40 commit 2a81460
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions plugins/versionpress/src/Git/merge-drivers/ini-merge.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@

}
// Add temporary placeholder between adjacent lines to prevent merge conflicts
file_put_contents($B, preg_replace('/(\r\n|\r|\n)/', "$1#######\n", $bFile));
file_put_contents($A, preg_replace('/(\r\n|\r|\n)/', "$1#######\n", $aFile));
file_put_contents($O, preg_replace('/(\r\n|\r|\n)/', "$1#######\n", $oFile));
file_put_contents($B, preg_replace('/(\r\n|\r|\n)/', "$1###VP###\n", $bFile));
file_put_contents($A, preg_replace('/(\r\n|\r|\n)/', "$1###VP###\n", $aFile));
file_put_contents($O, preg_replace('/(\r\n|\r|\n)/', "$1###VP###\n", $oFile));

// Call git merge command and receive the exitcode
exec($mergeCommand, $dummy, $mergeExitCode);

// Remove temporary placeholders
file_put_contents($B, str_replace("#######\n", '', file_get_contents($B)));
file_put_contents($A, str_replace("#######\n", '', file_get_contents($A)));
file_put_contents($O, str_replace("#######\n", '', file_get_contents($O)));
file_put_contents($B, str_replace("###VP###\n", '', file_get_contents($B)));
file_put_contents($A, str_replace("###VP###\n", '', file_get_contents($A)));
file_put_contents($O, str_replace("###VP###\n", '', file_get_contents($O)));

exit ($mergeExitCode);
12 changes: 6 additions & 6 deletions plugins/versionpress/src/Git/merge-drivers/ini-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ do
done

# Place temporary placeholder between lines to avoid merge conflicts on adjacent lines
sed -i '' -e ':a' -e 'N' -e '$!ba' -e 's/\n/&#######&/g' $O
sed -i '' -e ':a' -e 'N' -e '$!ba' -e 's/\n/&#######&/g' $A
sed -i '' -e ':a' -e 'N' -e '$!ba' -e 's/\n/&#######&/g' $B
sed -i '' -e ':a' -e 'N' -e '$!ba' -e 's/\n/&###VP###&/g' $O
sed -i '' -e ':a' -e 'N' -e '$!ba' -e 's/\n/&###VP###&/g' $A
sed -i '' -e ':a' -e 'N' -e '$!ba' -e 's/\n/&###VP###&/g' $B

# Process everything else through standard
git merge-file -L mine -L base -L theirs $A $O $B
Expand All @@ -50,9 +50,9 @@ git merge-file -L mine -L base -L theirs $A $O $B
GIT_MERGE_EXIT_CODE=$?

# Remove temporary placeholders
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n#######//g' -i '' $A
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n#######//g' -i '' $B
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n#######//g' -i '' $O
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n###VP###//g' -i '' $A
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n###VP###//g' -i '' $B
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n###VP###//g' -i '' $O

# If Git merge fails, we should also 'fail'
if [ $GIT_MERGE_EXIT_CODE -ne 0 ]; then
Expand Down

0 comments on commit 2a81460

Please sign in to comment.