Created
February 13, 2019 16:31
-
-
Save grekko/9c16bd75cbbe1a867ff33566fa46c364 to your computer and use it in GitHub Desktop.
Problematic git merge w/ empty source comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msgid "" | |
msgstr "" | |
"MIME-Version: 1.0\n" | |
"Content-Type: text/plain; charset=UTF-8\n" | |
"Content-Transfer-Encoding: 8bit\n" | |
"X-Generator: POEditor.com\n" | |
"Project-Id-Version: Default\n" | |
"Language: de\n" | |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | |
#: | |
msgid "Hello World" | |
msgstr "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msgid "" | |
msgstr "" | |
"MIME-Version: 1.0\n" | |
"Content-Type: text/plain; charset=UTF-8\n" | |
"Content-Transfer-Encoding: 8bit\n" | |
"X-Generator: POEditor.com\n" | |
"Project-Id-Version: Default\n" | |
"Language: de\n" | |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | |
msgid "Hello World" | |
msgstr "" | |
msgid "A new translation" | |
msgstr "" | |
msgid "And another translation" | |
msgstr "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# ******************************************* | |
# WARNING: this does *not* handle 3-way merges properly. | |
# Anything modified on the local branch since the common base will get ignored. | |
# | |
# FOR ANYONE LANDING HERE: | |
# This script is now updated as part of the git-whistles gem. | |
# https://github.com/mezis/git-whistles | |
# ******************************************* | |
# | |
# Custom Git merge driver - merges PO files using msgcat(1) | |
# | |
# - Install gettext | |
# | |
# - Place this script in your PATH | |
# | |
# - Add this to your .git/config : | |
# | |
# [merge "pofile"] | |
# name = Gettext merge driver | |
# driver = git merge-po %O %A %B | |
# | |
# - Add this to .gitattributes : | |
# | |
# *.po merge=pofile | |
# *.pot merge=pofile | |
# | |
# - When merging branches, conflicts in PO files will be maked with "#-#-#-#" | |
# | |
O=$1 | |
A=$2 | |
B=$3 | |
# Extract the PO header from the current branch (top of file until first empty line) | |
header=$(mktemp /tmp/merge-po.XXXX) | |
sed -e '/^$/q' < $A > $header | |
# Merge files, then repair header | |
temp=$(mktemp /tmp/merge-po.XXXX) | |
msgcat -o $temp $A $B | |
msgcat --use-first -o $A $header $temp | |
# Clean up | |
rm $header $temp | |
# Check for conflicts | |
conflicts=$(grep -c "#-#" $A) | |
test $conflicts -gt 0 && exit 1 | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
./git-merge-po.sh ancestor.po current.po other.po |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msgid "" | |
msgstr "" | |
"MIME-Version: 1.0\n" | |
"Content-Type: text/plain; charset=UTF-8\n" | |
"Content-Transfer-Encoding: 8bit\n" | |
"X-Generator: POEditor.com\n" | |
"Project-Id-Version: Default\n" | |
"Language: de\n" | |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | |
#: | |
msgid "And another translation" | |
msgstr "" | |
#: | |
msgid "Hello World" | |
msgstr "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment