diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-12-16 15:27:48 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-12-16 15:27:48 -0800 |
commit | 2cf8c9053afbb666dc30f384d313e3e85e00d53a (patch) | |
tree | fd01ddd420738378def4893a367ea88441aa348c /t | |
parent | 7e73488b46b317eea289373eed15086feb0cd959 (diff) | |
parent | 4df1d4d4666eb26b420d5b386010470729846b8c (diff) | |
download | git-2cf8c9053afbb666dc30f384d313e3e85e00d53a.tar.gz git-2cf8c9053afbb666dc30f384d313e3e85e00d53a.tar.xz |
Merge branch 'nd/worktree-list-fixup'
The output from "git worktree list" was made in readdir() order,
and was unstable.
* nd/worktree-list-fixup:
worktree list: keep the list sorted
worktree.c: get_worktrees() takes a new flag argument
get_worktrees() must return main worktree as first item even on error
worktree: reorder an if statement
worktree.c: zero new 'struct worktree' on allocation
Diffstat (limited to 't')
-rwxr-xr-x | t/t2027-worktree-list.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/t/t2027-worktree-list.sh b/t/t2027-worktree-list.sh index 1b1b65a6b..465eeeacd 100755 --- a/t/t2027-worktree-list.sh +++ b/t/t2027-worktree-list.sh @@ -96,4 +96,44 @@ test_expect_success 'bare repo cleanup' ' rm -rf bare1 ' +test_expect_success 'broken main worktree still at the top' ' + git init broken-main && + ( + cd broken-main && + test_commit new && + git worktree add linked && + cat >expected <<-EOF && + worktree $(pwd) + HEAD $_z40 + + EOF + cd linked && + echo "worktree $(pwd)" >expected && + echo "ref: .broken" >../.git/HEAD && + git worktree list --porcelain | head -n 3 >actual && + test_cmp ../expected actual && + git worktree list | head -n 1 >actual.2 && + grep -F "(error)" actual.2 + ) +' + +test_expect_success 'linked worktrees are sorted' ' + mkdir sorted && + git init sorted/main && + ( + cd sorted/main && + test_tick && + test_commit new && + git worktree add ../first && + git worktree add ../second && + git worktree list --porcelain | grep ^worktree >actual + ) && + cat >expected <<-EOF && + worktree $(pwd)/sorted/main + worktree $(pwd)/sorted/first + worktree $(pwd)/sorted/second + EOF + test_cmp expected sorted/main/actual +' + test_done |