#!/bin/sh

git=git

[ -e dir ] && { echo \"dir\" already exists. Remove it and try again. >&2; exit 1; }
set | grep -e ^LC_ -e ^LANG
echo
$git init dir
cd dir || { echo Cannot chdir >&2; exit 1; }
$git commit -m "Initial commit" --allow-empty
$git tag firstrev
echo; echo ======== Create commits
echo First line >foo.txt
$git add foo.txt
$git commit -m "First commit without 8-bit chars"
echo Second line >>foo.txt
$git commit -m "Second commit with © in first line of logmsg" -a
echo Third line >>foo.txt
$git commit -m "Third commit with no 8-bit in first line`echo; echo but €uro further down`" -a
echo Fourth line >>foo.txt
$git commit -m "Fourth commit with © in first line again" -a
echo; echo ======== $git format-patch firstrev
$git format-patch firstrev
echo; echo ======== Create new, empty branch and apply patches
$git checkout -b patches firstrev
$git am 0*
echo; echo ======== $git log
$git log
