#!/bin/bash

# gitmk-intend -- Save manually prepared content as your intention (to be checked against later).
#
# When to use:
# 
# You prepared the current tree manually, but thought that you'd
# better generate it with a rule (GOAL).
# So you want to save the current tree as your "intention" first,
# (and later, if you see any discrepancies between the automatically
# produced result and your saved intention, you might want to fix your
# rule).

set -e # exit on any error immediately!

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

set -x

# Saving the manually prepared content in the auxiliary branches:

git branch "$BRANCH"_/AUTO/"$GOAL" "$BRANCH"
git branch "$BRANCH"_/OUT/"$GOAL" "$BRANCH"_/AUTO/"$GOAL"

# Then you want to write the rule (in Makefile), 
# git rm your manually prepared content in the current BRANCH,
# gitmk-make GOAL.
# And the result of automatic generation will be checked against
# the saved intention.

