#!/bin/bash

# gitmk-start -- create the auxiliary branches (that will go along our branch).

set -e # exit on any error immediately!

readonly GOAL="$1"

readonly headref="$(git symbolic-ref HEAD)"
readonly BRANCH="${headref##refs/heads/}"

set -x

if git checkout -b "$BRANCH"_/AUTO/"$GOAL" \
    && make "$GOAL";
then
    set +x
    printf $"Now, git add what you need, and git commit, and git checkout -b %s_/OUT/%s , and tweak it." "$BRANCH" "$GOAL"
    echo
else
    readonly status=$?
    git checkout "$BRANCH"
    set +x
    printf $"make %s failed; now, fix the sources here." "$GOAL"
    echo
    exit $status
fi