]> granicus.if.org Git - git/commitdiff
reset: unstage empty deleted ita files
authorVarun Naik <vcnaik94@gmail.com>
Fri, 26 Jul 2019 04:48:06 +0000 (21:48 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Jul 2019 16:55:05 +0000 (09:55 -0700)
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>
builtin/reset.c
t/t7102-reset.sh

index 26ef9a7bd03ac8925e1cb350c49e5e327999ba52..47a088f4b737e47b0f5a2b9fedd06be8f8ba8e00 100644 (file)
@@ -163,6 +163,7 @@ static int read_from_tree(const struct pathspec *pathspec,
        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;
index 97be0d968dbcedba226b39862faddd23da39d863..a99e97cb6f1c544a558647e46a1a73f93539e0aa 100755 (executable)
@@ -566,4 +566,15 @@ test_expect_success 'reset --mixed sets up work tree' '
        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