diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2020-12-19 14:55:59 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-12-21 14:06:09 -0800 |
commit | 5c29f19cdada762e75939a946df21b44d48d6fff (patch) | |
tree | bdc9d8ad8daf17aee9dff42c439c46b74968a342 /t/t2016-checkout-patch.sh | |
parent | 35166b1fb54d6c3ca0d9150fd766598a2d3d17b2 (diff) | |
download | git-5c29f19cdada762e75939a946df21b44d48d6fff.tar.gz |
checkout -p: handle tree arguments correctly again
This fixes a segmentation fault.
The bug is caused by dereferencing `new_branch_info->commit` when it is
`NULL`, which is the case when the tree-ish argument is actually a tree,
not a commit-ish. This was introduced in 5602b500c3c (builtin/checkout:
fix `git checkout -p HEAD...` bug, 2020-10-07), where we tried to ensure
that the special tree-ish `HEAD...` is handled correctly.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2016-checkout-patch.sh')
-rwxr-xr-x | t/t2016-checkout-patch.sh | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/t/t2016-checkout-patch.sh b/t/t2016-checkout-patch.sh index d91a329eb3..abfd586c32 100755 --- a/t/t2016-checkout-patch.sh +++ b/t/t2016-checkout-patch.sh @@ -123,4 +123,9 @@ test_expect_success PERL 'none of this moved HEAD' ' verify_saved_head ' +test_expect_success PERL 'empty tree can be handled' ' + test_when_finished "git reset --hard" && + git checkout -p $(test_oid empty_tree) -- +' + test_done |