diff options
author | Teddy Wing | 2018-04-19 23:46:46 +0200 |
---|---|---|
committer | Teddy Wing | 2018-04-19 23:46:46 +0200 |
commit | d53b95e8698031ba13d9fcb3fad6732a93729888 (patch) | |
tree | f928f9fbf3cb33032477e468f3510f2f5506a170 | |
parent | d1617e2f29d1a8080602b60cd83ffddb01e88875 (diff) | |
parent | 3f6e62684b1fb1167435c6fa4f6c6f02aaff3937 (diff) | |
download | git-branch-list-d53b95e8698031ba13d9fcb3fad6732a93729888.tar.bz2 |
Merge branch 'fix-drop-for-branch-names-with-slashes'
-rwxr-xr-x | git-branch-list | 5 | ||||
-rw-r--r-- | t/104-drop-works-with-branch-names-with-slashes.t | 29 |
2 files changed, 31 insertions, 3 deletions
diff --git a/git-branch-list b/git-branch-list index 75167a3..cce35e3 100755 --- a/git-branch-list +++ b/git-branch-list @@ -78,10 +78,9 @@ function drop_branch () { done for branch in "${branch_names[@]}"; do - sed -i '.bak' "/^$branch$/d" "$DATABASE" + fgrep --line-regexp --invert-match "$branch" "$DATABASE" > "$DATABASE.bak" + mv "${DATABASE}.bak" "$DATABASE" done - - rm "${DATABASE}.bak" } function clear_branches () { diff --git a/t/104-drop-works-with-branch-names-with-slashes.t b/t/104-drop-works-with-branch-names-with-slashes.t new file mode 100644 index 0000000..8219e3e --- /dev/null +++ b/t/104-drop-works-with-branch-names-with-slashes.t @@ -0,0 +1,29 @@ +#!/usr/bin/env perl -w + +use strict; + +use Test::More; + +use Bin qw($BIN); + +chdir 't-git-repo' or die $!; + +system('git checkout -b feature/with-slashes'); +ok !$?; + +system("$BIN save"); +ok !$?; + +system("$BIN drop"); +ok !$?; + +my $branch_list = qx($BIN); +is $branch_list, ''; + + +# Teardown +system('git checkout master'); +system('git branch -d feature/with-slashes'); + + +done_testing; |