#! /bin/sh

# This should be executed in a clean working copy of the test repo.

set -e
set -x

BASE="$(dirname "$(cd $(dirname "$0") && pwd)")"
TMP="$BASE/t/tmp"
GIT_IMERGE="$BASE/git-imerge"

cd "$TMP"

# Clean up detritus from possible previous runs:
git checkout master
"$GIT_IMERGE" remove --name=a-b || true
for b in a-b-merge a-b-rebase a-b-rebase-with-history a-b-full
do
    git branch -D $b || true
done

git checkout a
"$GIT_IMERGE" start --first-parent --name=a-b --branch=a-b-merge b
"$GIT_IMERGE" list
"$GIT_IMERGE" diagram --commits --frontier --html=imerge3.html
GIT_EDITOR=cat "$GIT_IMERGE" simplify --goal=merge --branch=a-b-merge
"$GIT_IMERGE" simplify --goal=rebase --branch=a-b-rebase
"$GIT_IMERGE" simplify --goal=rebase-with-history --branch=a-b-rebase-with-history
"$GIT_IMERGE" remove

git checkout a
"$GIT_IMERGE" start --goal=full --first-parent --name=a-b b
"$GIT_IMERGE" list
"$GIT_IMERGE" diagram --commits --frontier --html=imerge4.html
"$GIT_IMERGE" finish --branch=a-b-full

