summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYvan Roux <yvan.roux@linaro.org>2015-07-22 13:16:44 +0000
committerLinaro Code Review <review@review.linaro.org>2015-07-22 13:16:44 +0000
commitbdea9d0c459d4be23cec77332f73492fb4217529 (patch)
tree32177a58cea07f0c8a7abc7ff289c6b49d8d5cbd
parentf6db8237fe6a2df82627d3ec7aedb85cdfe27bac (diff)
parentf469c613e8c275ce8a9df993ee8289447a97202c (diff)
Merge "Fix race in clean() where it might try to delete the current branch."
-rwxr-xr-xtcwg-release.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/tcwg-release.sh b/tcwg-release.sh
index ed8f756..833aaed 100755
--- a/tcwg-release.sh
+++ b/tcwg-release.sh
@@ -205,6 +205,12 @@ clean() {
# there.
popd &>/dev/null
+ # Return the tree to the starting branch if it's not already there. We
+ # can't be in one of the working branches if we want to delete it.
+ if [ "${save_branch+:set}" = "set" ]; then
+ git checkout ${save_branch} 1>/dev/null
+ fi
+
ask "May I remove ${REL_DIR}/git [N/y] ?" user_ok
if [ "$user_ok" = "y" ]; then
if [ -d "$REL_DIR/git" ]; then
@@ -590,6 +596,10 @@ if [ "x${track}" = "x" ]; then
BRANCH=$track
fi
+# Keep track of the branch we start from because we'll want to return there at
+# the end or if we have to cleanup prematurely.
+save_branch="$(git rev-parse --abbrev-ref HEAD)"
+
# Test to make sure the branch or tag exists
git rev-parse --abbrev-ref $track &>/dev/null || die "${TAG:+Tag }${BRANCH:+Branch }\"$track\" doesn't exist."