2021-07-20 07:52:24 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# branchname - print current branchname, including during rebase
|
|
|
|
#
|
|
|
|
# https://stackoverflow.com/questions/34213120/find-branch-name-during-git-rebase
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
branchname=$(git bn)
|
|
|
|
if [ "$branchname" = "HEAD" ]; then
|
2023-10-07 08:43:32 +00:00
|
|
|
if ! branchoutput=$(git branch --list | grep rebasing); then
|
2021-07-20 07:52:24 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
regex="rebasing ([^)]+)\)"
|
|
|
|
if [[ $branchoutput =~ $regex ]]; then
|
|
|
|
branchname="${BASH_REMATCH[1]}"
|
|
|
|
else
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-10-07 08:43:32 +00:00
|
|
|
printf "%s" "$branchname"
|