difftool: ensure full index

Before iterating over all cache entries, ensure that a sparse index has been expanded to a full one to avoid unexpected behavior. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Apr 1, 2021 at 01:49 UTC 48b3c7da6c58752b0fbc73e891fd5b24c95281b1
1 file changed +3
builtin/difftool.c
+3
@@ -584,6 +584,9 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
584 setenv("GIT_DIFFTOOL_DIRDIFF", "true", 1);
585 rc = run_command_v_opt(helper_argv, flags);
586
587 + /* TODO: audit for interaction with sparse-index. */
588 + ensure_full_index(&wtindex);
589 +
590 /*
591 * If the diff includes working copy files and those
592 * files were modified during the diff, then the changes