Skip to content

Commit 76bb16d

Browse files
committed
Merge branch 'sm/difftool'
Use of some uninitialized variables in "git difftool" has been corrected. * sm/difftool: builtin/difftool: intialize some hashmap variables
2 parents aa1d4b4 + 98e4015 commit 76bb16d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

builtin/difftool.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
376376
struct checkout lstate, rstate;
377377
int err = 0;
378378
struct child_process cmd = CHILD_PROCESS_INIT;
379-
struct hashmap wt_modified, tmp_modified;
379+
struct hashmap wt_modified = HASHMAP_INIT(path_entry_cmp, NULL);
380+
struct hashmap tmp_modified = HASHMAP_INIT(path_entry_cmp, NULL);
380381
int indices_loaded = 0;
381382

382383
workdir = repo_get_work_tree(the_repository);
@@ -601,9 +602,6 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
601602
* in the common case of --symlinks and the difftool updating
602603
* files through the symlink.
603604
*/
604-
hashmap_init(&wt_modified, path_entry_cmp, NULL, wtindex.cache_nr);
605-
hashmap_init(&tmp_modified, path_entry_cmp, NULL, wtindex.cache_nr);
606-
607605
for (i = 0; i < wtindex.cache_nr; i++) {
608606
struct hashmap_entry dummy;
609607
const char *name = wtindex.cache[i]->name;

t/t7800-difftool.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' '
666666
test_cmp expect file
667667
'
668668

669+
run_dir_diff_test 'difftool --dir-diff with no diff' '
670+
git difftool -d main main
671+
'
672+
669673
write_script modify-file <<\EOF
670674
echo "new content" >file
671675
EOF

0 commit comments

Comments
 (0)