aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-03-18 20:36:21 +0100
committerTeddy Wing2018-03-18 20:36:21 +0100
commita33c35b0561162306169fae17452a5b521ece067 (patch)
tree040d97598003e21ff2e4bd559329814fb2604e4a
parent975b9d397076e26ba205a71cac4a5db190d873f9 (diff)
downloadgit-branch-list-a33c35b0561162306169fae17452a5b521ece067.tar.bz2
git-branch-list(drop): Show error message when branch not found
Instead of displaying the underlying errors: sed: first RE may not be empty rm: .git/info/git-branch-list.bak: No such file or directory display a meaningful error message from our program to let users know that the given branch couldn't be found in the branch-list database.
-rwxr-xr-xgit-branch-list6
1 files changed, 6 insertions, 0 deletions
diff --git a/git-branch-list b/git-branch-list
index 1468bfe..c37ef74 100755
--- a/git-branch-list
+++ b/git-branch-list
@@ -54,12 +54,18 @@ function save_branch () {
function drop_branch () {
local branch=$(branch_or_current_branch "$1")
+ local input="$branch"
# Assume `$branch` is an ID if it's not a branch name
if ! is_a_branch "$branch"; then
branch=$(branch_by_id "$branch")
fi
+ if [ -z "$branch" ]; then
+ echo "branch-list: Unrecognised branch '$input'" 1>&2
+ exit 1
+ fi
+
sed -i '.bak' "/$branch/d" "$DATABASE"
rm "${DATABASE}.bak"
}