diff options
author | Teddy Wing | 2020-03-13 01:24:52 +0100 |
---|---|---|
committer | Teddy Wing | 2020-03-13 01:24:52 +0100 |
commit | d57fed7924c986c617a18cb260b0a5bc0228cbb4 (patch) | |
tree | aa8c40e014cb30a1b1384b01b336fed82ff524b8 | |
parent | 73b82527df51dc093455ae4149799c278c1dcffc (diff) | |
parent | 39ab4b571f331d42a8a3485e811e17dfaf72a930 (diff) | |
download | git-branch-list-d57fed7924c986c617a18cb260b0a5bc0228cbb4.tar.bz2 |
-rw-r--r-- | CHANGELOG | 5 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | git-branch-list | 8 | ||||
-rw-r--r-- | t/108-works-with-git-worktrees.t | 36 |
4 files changed, 46 insertions, 5 deletions
@@ -1,6 +1,11 @@ CHANGELOG ========= +v0.1.4 (2020-03-13): + Fixes: + + * The database file can now be correctly located when in a worktree. + v0.1.3 (2019-12-09): Fixes: @@ -48,5 +48,5 @@ On other platforms, grab the code and put the `git-branch-list` script in your ## License -Copyright © 2018–2019 Teddy Wing. Licensed under the GNU GPLv3+ (see the +Copyright © 2018–2020 Teddy Wing. Licensed under the GNU GPLv3+ (see the included COPYING file). diff --git a/git-branch-list b/git-branch-list index b70b106..24eb5b7 100755 --- a/git-branch-list +++ b/git-branch-list @@ -3,7 +3,7 @@ # git-branch-list # Maintains a list of Git branches that can be checked out quickly. -# Copyright (c) 2018–2019 Teddy Wing +# Copyright (c) 2018–2020 Teddy Wing # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,9 +18,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. -GIT_ROOT=$(git rev-parse --show-toplevel) -DATABASE="${GIT_ROOT}/.git/info/git-branch-list" -VERSION=0.1.3 +GIT_ROOT="$(git rev-parse --git-common-dir)" +DATABASE="${GIT_ROOT}/info/git-branch-list" +VERSION=0.1.4 function initialise_database () { if [ -d .git ]; then diff --git a/t/108-works-with-git-worktrees.t b/t/108-works-with-git-worktrees.t new file mode 100644 index 0000000..b2901c0 --- /dev/null +++ b/t/108-works-with-git-worktrees.t @@ -0,0 +1,36 @@ +#!/usr/bin/env perl -w + +use strict; + +use Test::More; +use File::Path qw(remove_tree); + +use Bin qw($BIN); + +chdir 't-git-repo' or die $!; + +system('git branch a-branch'); +ok !$?; + +system("$BIN save a-branch"); +ok !$?; + +system('git worktree add ../t-git-repo-worktree'); +ok !$?; + +chdir '../t-git-repo-worktree' or die $!; + +my $branch_list = qx($BIN); +is $branch_list, ' 1 a-branch +'; + + +# Teardown +system("$BIN clear"); +chdir '../t-git-repo' or die $!; +remove_tree('../t-git-repo-worktree') or die $!; +system('git checkout master'); +system('git branch -d a-branch'); + + +done_testing; |