Files
git/builtin
Patrick Steinhardt e3209bd4df builtin/stash: fix --keep-index --include-untracked with empty HEAD
It was reported that creating a stash with `--keep-index
--include-untracked` causes an error when HEAD points to a commit whose
tree is empty:

    $ git stash push --keep-index --include-untracked
    error: pathspec ':/' did not match any file(s) known to git

This error comes from `git checkout --no-overlay $i_tree -- :/`, which
we execute to reset the working tree to the state in our index. As the
tree generated from the index is empty in our case, ':/' does not match
any files and thus causes git-checkout(1) to error out.

Fix the issue by skipping the checkout when the index tree is empty. As
explained in the in-code comment, this should be the correct thing to do
as there is nothing that we'd have to reset in the first place.

Reported-by: Piotr Siupa <piotrsiupa@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-08-16 09:50:33 -07:00
..
2023-02-22 14:55:45 -08:00
2022-04-06 09:42:14 -07:00
2023-01-13 14:17:14 -08:00
2023-02-22 14:55:45 -08:00
2021-10-28 09:57:09 -07:00
2022-12-14 15:55:46 +09:00
2022-11-23 11:22:24 +09:00
2023-02-22 14:55:45 -08:00
2022-11-16 14:57:32 -05:00
2023-02-15 17:11:53 -08:00
2023-02-22 14:55:45 -08:00
2024-04-19 12:38:37 +02:00
2022-12-18 11:48:26 +09:00