diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2022-01-26 14:05:38 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-01-26 21:08:52 +0100 |
commit | 69f4c23009ee30faeb61a831f4265791c945783e (patch) | |
tree | 4521a6bcadf828e73d54b9e5f30c1c686a2623d2 /t/t5403-post-checkout-hook.sh | |
parent | t5403: refactor rebase post-checkout hook tests (diff) | |
download | git-69f4c23009ee30faeb61a831f4265791c945783e.tar.xz git-69f4c23009ee30faeb61a831f4265791c945783e.zip |
rebase: pass correct arguments to post-checkout hook
If a rebase started with "rebase [--apply|--merge] <upstream> <branch>"
detects that <upstream> is an ancestor of <branch> then it fast-forwards
and checks out <branch>. 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 <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5403-post-checkout-hook.sh')
-rwxr-xr-x | t/t5403-post-checkout-hook.sh | 13 |
1 files changed, 13 insertions, 0 deletions
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 && |