#!/bin/sh

#set -x
set -e

cd /tmp/
rm -rf unmergeable && mkdir unmergeable
cd unmergeable

git init
echo "original content" > test_file
git add -f test_file
git commit -m "Add a test_file" test_file

tg create A
git add -f .topmsg .topdeps
git commit -m "Create branch A"
echo A >> test_file
git commit -m "Add changes in branch A" test_file
tg summary --graphviz > 01_Create_A.dot

git checkout master 

tg create B
git add -f .topmsg .topdeps
git commit -m "Create branch B"
echo B >> test_file
git commit -m "Add changes in branch B" test_file
tg summary --graphviz > 02_Create_B.dot

git checkout B
tg create C
git add -f .topmsg .topdeps
git commit -m "Create branch C"
tg summary --graphviz > 03_Create_C.dot

set +e

tg depend add A
tg summary --graphviz > 04_C_depnd_on_A.dot

for f in *.dot;
do
  dot -Tpng "$f" > "$(basename "$f" .dot).png"
done
