#!/bin/bash

# gitmk-drop -- delete the auxiliary branches.

set -e # exit on any error immediately!

readonly GOAL="$1"

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

set -x

git branch -D "$BRANCH"_/OUT/"$GOAL"

# Sometimes it happens that "$BRANCH"_/OUT/"$GOAL" doesn't exist, so
# the script aborts here, and doesn't delete the AUTO branch...
# 
# Well, you can simply handle that case manually, because who knows
# what went wrong...

git branch -D "$BRANCH"_/AUTO/"$GOAL"
