Skip to content

Commit

Permalink
Merge branch 'sm/difftool'
Browse files Browse the repository at this point in the history
Use of some uninitialized variables in "git difftool" has been
corrected.

* sm/difftool:
  builtin/difftool: intialize some hashmap variables
  • Loading branch information
gitster committed Nov 22, 2024
2 parents aa1d4b4 + 98e4015 commit 76bb16d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 2 additions & 4 deletions builtin/difftool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions t/t7800-difftool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 76bb16d

Please sign in to comment.