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>
This commit is contained in:
committed by
Junio C Hamano
parent
bd55eee04b
commit
69f4c23009
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user