From 69f4c23009ee30faeb61a831f4265791c945783e Mon Sep 17 00:00:00 2001 From: Phillip Wood Date: Wed, 26 Jan 2022 13:05:38 +0000 Subject: rebase: pass correct arguments to post-checkout hook If a rebase started with "rebase [--apply|--merge] " detects that is an ancestor of then it fast-forwards and checks out . Unfortunately in that case it passed the null oid as the first argument to the post-checkout hook rather than the oid of HEAD. A side effect of this change is that the call to update_ref() which updates HEAD now always receives the old value of HEAD. This provides protection against another process updating HEAD during the checkout. Signed-off-by: Phillip Wood Signed-off-by: Junio C Hamano --- t/t5403-post-checkout-hook.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 't') diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh index 272b02687b..17ab518f26 100755 --- a/t/t5403-post-checkout-hook.sh +++ b/t/t5403-post-checkout-hook.sh @@ -72,6 +72,19 @@ test_rebase () { test_cmp_rev rebase-on-me $new && test $flag = 1 ' + + test_expect_success "rebase $args fast-forward branch checkout runs post-checkout hook" ' + test_when_finished "test_might_fail git rebase --abort" && + test_when_finished "rm -f .git/post-checkout.args" && + git update-ref refs/heads/rebase-fast-forward three && + git checkout two && + rm -f .git/post-checkout.args && + git rebase $args HEAD rebase-fast-forward && + read old new flag <.git/post-checkout.args && + test_cmp_rev two $old && + test_cmp_rev three $new && + test $flag = 1 + ' } test_rebase --apply && -- cgit v1.3