Setting GIT_DIR alone means worktree is current directory for legacy reasons. Avoid using that, instead go to the worktree and execute commands there. The troublesome command is "GIT_DIR=clone2/.git git add clone2/b". The real worktree is clone2, but that command tells git worktree is $(pwd). What does user expect to add then? Should the new entry in index be "b" or "clone2/b"? Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- t/t5403-post-checkout-hook.sh | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh index 6643f32..3459539 100755 --- a/t/t5403-post-checkout-hook.sh +++ b/t/t5403-post-checkout-hook.sh @@ -13,10 +13,13 @@ test_expect_success setup ' git commit -m setup && git clone ./. clone1 && git clone ./. clone2 && - GIT_DIR=clone2/.git git branch new2 && - echo Data for commit1. >clone2/b && - GIT_DIR=clone2/.git git add clone2/b && - GIT_DIR=clone2/.git git commit -m new2 + ( + cd clone2 && + git branch new2 && + echo Data for commit1. >b && + git add b && + git commit -m new2 + ) ' for clone in 1 2; do @@ -45,7 +48,7 @@ test_expect_success 'post-checkout runs as expected ' ' ' test_expect_success 'post-checkout args are correct with git checkout -b ' ' - GIT_DIR=clone1/.git git checkout -b new1 && + ( cd clone1 && git checkout -b new1 ) && old=$(awk "{print \$1}" clone1/.git/post-checkout.args) && new=$(awk "{print \$2}" clone1/.git/post-checkout.args) && flag=$(awk "{print \$3}" clone1/.git/post-checkout.args) && @@ -53,7 +56,7 @@ test_expect_success 'post-checkout args are correct with git checkout -b ' ' ' test_expect_success 'post-checkout receives the right args with HEAD changed ' ' - GIT_DIR=clone2/.git git checkout new2 && + ( cd clone2 && git checkout new2 ) && old=$(awk "{print \$1}" clone2/.git/post-checkout.args) && new=$(awk "{print \$2}" clone2/.git/post-checkout.args) && flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) && @@ -61,7 +64,7 @@ test_expect_success 'post-checkout receives the right args with HEAD changed ' ' ' test_expect_success 'post-checkout receives the right args when not switching branches ' ' - GIT_DIR=clone2/.git git checkout master b && + ( cd clone2 && git checkout master b ) && old=$(awk "{print \$1}" clone2/.git/post-checkout.args) && new=$(awk "{print \$2}" clone2/.git/post-checkout.args) && flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) && -- 1.7.3.1.256.g2539c.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html