Skip to content

Commit 8a02132

Browse files
committed
diff: munmap() file contents before running external diff
When running an external diff from, say, a diff tool, it is safe to assume that we want to write the files in question. On Windows, that means that there cannot be any other process holding an open handle to said files, or even just a mapped region. So let's make sure that `git diff` itself is not holding any open handle to the files in question. In fact, we will just release the file pair right away, as the external diff uses the files we just wrote, so we do not need to hold the file contents in memory anymore. This fixes git-for-windows#1315 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent aa25c82 commit 8a02132

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

diff.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4206,6 +4206,8 @@ static void run_external_diff(const char *pgm,
42064206
argv_array_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter);
42074207
argv_array_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr);
42084208

4209+
diff_free_filespec_data(one);
4210+
diff_free_filespec_data(two);
42094211
if (run_command_v_opt_cd_env(argv.argv, RUN_USING_SHELL, NULL, env.argv))
42104212
die(_("external diff died, stopping at %s"), name);
42114213

0 commit comments

Comments
 (0)