#!/bin/bash
#
# Two-way merge driver for PO files
#
# Copyright 2026 Osamu Aoki
#
# salvage-po $tag files...
TAG="$1"
shift
#
##########################################################################
MSGCAT_NO_WRAP="msgcat --no-wrap"
MSGCAT_USE_1ST="msgcat --use-first"

echo "TAG=$TAG"

for f in $@; do
  $MSGCAT_NO_WRAP "$f" -o "$f.new"
done

for f in $@; do
  git checkout "$TAG" -- "$f"
  $MSGCAT_NO_WRAP "$f" -o "$f.old"
  $MSGCAT_USE_1ST "$f.new" "$f.old" -o "$f"
  git add "$f"
done

echo "run 'make test; make wrapx'"

