It is possible to delete a committed file from the index and then add it
as intent-to-add. After `git reset HEAD`, the file should be identical
in the index and HEAD. This patch provides the desired behavior even
when the file is empty in the index.
Signed-off-by: Varun Naik <vcnaik94@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
opt.format_callback_data = &intent_to_add;
opt.flags.override_submodule_config = 1;
opt.repo = the_repository;
+ opt.ita_invisible_in_index = 1;
if (do_diff_cache(tree_oid, &opt))
return 1;
test_must_be_empty actual
'
+test_expect_success 'reset --mixed adds deleted intent-to-add file back to index' '
+ echo "nonempty" >nonempty &&
+ >empty &&
+ git add nonempty empty &&
+ git commit -m "create files to be deleted" &&
+ git rm --cached nonempty empty &&
+ git add -N nonempty empty &&
+ git reset HEAD nonempty empty &&
+ git diff --cached --exit-code HEAD
+'
+
test_done