From 92b7edb0d84ac0109f28da57fccf4a9d87896b1e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 19 Apr 2018 23:17:22 +0200 Subject: git-branch-list(save): Allow saving branches with similar names It wasn't possible to save branches with similar names before: $ git branch-list save a-branch-with-suffix $ git branch-list save a-branch #=> Errors $ git branch-list 1 a-branch-with-suffix This is because I wasn't matching against the whole line, so partial matches would set off the condition and exit. Use grep's `--line-regexp` flag to match against whole lines. Thanks to John Kugelman for the flag: https://stackoverflow.com/questions/4709912/how-to-make-grep-only-match-if-the-entire-line-matches/4709925#4709925 --- git-branch-list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-branch-list b/git-branch-list index cde44f2..75167a3 100755 --- a/git-branch-list +++ b/git-branch-list @@ -44,7 +44,7 @@ __EOF__ function save_branch () { local branch=$(branch_or_current_branch "$1") - if fgrep "$branch" "$DATABASE" > /dev/null; then + if fgrep --line-regexp "$branch" "$DATABASE" > /dev/null; then return 1 fi -- cgit v1.2.3