aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgit-branch-list3
-rw-r--r--t/105-list-works-in-subdirectory.t17
2 files changed, 19 insertions, 1 deletions
diff --git a/git-branch-list b/git-branch-list
index 13b3ed1..ed5ef34 100755
--- a/git-branch-list
+++ b/git-branch-list
@@ -18,7 +18,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-DATABASE=.git/info/git-branch-list
+GIT_ROOT=$(git rev-parse --show-toplevel)
+DATABASE="${GIT_ROOT}/.git/info/git-branch-list"
VERSION=0.1.1
function initialise_database () {
diff --git a/t/105-list-works-in-subdirectory.t b/t/105-list-works-in-subdirectory.t
new file mode 100644
index 0000000..b236314
--- /dev/null
+++ b/t/105-list-works-in-subdirectory.t
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl -w
+
+use strict;
+
+use Test::More;
+
+use Bin qw($BIN);
+
+mkdir 't-git-repo/subdirectory', 0755;
+
+chdir 't-git-repo/subdirectory' or die $!;
+
+my $branch_list = qx($BIN);
+is $branch_list, '', 'must find database file';
+
+
+done_testing;