diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-01-17 14:49:27 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-17 14:49:27 -0800 |
commit | 430fd1cae522d1eff58478eb606bee996b52208f (patch) | |
tree | eaccc302090ec4c03de9481cbfd542879b072d9f /t | |
parent | 3075e40c75560d93b569d1bba715008ca734ad83 (diff) | |
parent | 4df1d4d4666eb26b420d5b386010470729846b8c (diff) | |
download | git-430fd1cae522d1eff58478eb606bee996b52208f.tar.gz git-430fd1cae522d1eff58478eb606bee996b52208f.tar.xz |
Merge branch 'nd/worktree-list-fixup' into maint
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 |