@@ -376,7 +376,8 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
struct checkout lstate, rstate;
int err = 0;
struct child_process cmd = CHILD_PROCESS_INIT;
- struct hashmap wt_modified, tmp_modified;
+ struct hashmap wt_modified = HASHMAP_INIT(path_entry_cmp, NULL);
+ struct hashmap tmp_modified = HASHMAP_INIT(path_entry_cmp, NULL);
int indices_loaded = 0;
workdir = repo_get_work_tree(the_repository);
@@ -601,9 +602,6 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
* in the common case of --symlinks and the difftool updating
* files through the symlink.
*/
- hashmap_init(&wt_modified, path_entry_cmp, NULL, wtindex.cache_nr);
- hashmap_init(&tmp_modified, path_entry_cmp, NULL, wtindex.cache_nr);
-
for (i = 0; i < wtindex.cache_nr; i++) {
struct hashmap_entry dummy;
const char *name = wtindex.cache[i]->name;
@@ -666,6 +666,10 @@ run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' '
test_cmp expect file
'
+run_dir_diff_test 'difftool --dir-diff with no diff' '
+ git difftool -d main main
+'
+
write_script modify-file <<\EOF
echo "new content" >file
EOF