aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-11-22 14:34:18 +0900
committerJunio C Hamano <gitster@pobox.com>2024-11-22 14:34:18 +0900
commit76bb16db5cf7fb6d5942d62bc4a7311e5f8faa7d (patch)
treeb7378fe6b320ba8a3492174f16e7fd7a8d355726
parentMerge branch 'jk/fetch-prefetch-double-free-fix' (diff)
parentbuiltin/difftool: intialize some hashmap variables (diff)
downloadgit-76bb16db5cf7fb6d5942d62bc4a7311e5f8faa7d.tar.gz
git-76bb16db5cf7fb6d5942d62bc4a7311e5f8faa7d.zip
Merge branch 'sm/difftool'
Use of some uninitialized variables in "git difftool" has been corrected. * sm/difftool: builtin/difftool: intialize some hashmap variables
-rw-r--r--builtin/difftool.c6
-rwxr-xr-xt/t7800-difftool.sh4
2 files changed, 6 insertions, 4 deletions
diff --git a/builtin/difftool.c b/builtin/difftool.c
index ca1b089065..40e971e225 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -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;
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index f67b9345b8..fcaa1748e4 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -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