#!/bin/bash

# gitmk-afteramend -- a simple stupid reset of the result branches for GOAL after you amended the source branch.

set -e # exit on any error immediately!

readonly GOAL="$1"

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

function rewind_branch() {
    git branch -f "$1" "$1"^
}

set -x

rewind_branch "$BRANCH"_/OUT/"$GOAL" \
&& rewind_branch "$BRANCH"_/AUTO/"$GOAL"
