Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2022-01-26 16:05:38 +0300
committerJunio C Hamano <gitster@pobox.com>2022-01-26 23:08:52 +0300
commit69f4c23009ee30faeb61a831f4265791c945783e (patch)
tree4521a6bcadf828e73d54b9e5f30c1c686a2623d2 /t/t5403-post-checkout-hook.sh
parentbd55eee04b698af6c10c77b24f88601814771ac8 (diff)
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-xt/t5403-post-checkout-hook.sh13
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 &&