blob: 96e5984ea1675bee2286f223474b381176596ea8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/bin/bash
#
# Custom Git merge driver - merges PO files using msgcat(1)
#
# To use this,
# git config merge.pofile.name "Gettext merge driver"
# git config merge.pofile.driver "src/po/git-merge-po %O %A %B"
#
# - When merging branches, conflicts in PO files will be maked with "#-#-#-#"
#
set -x
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
|