Skip to content

Commit 2ff3f70

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. So let's make sure that `git diff` itself is not holding any open handle to the files in question. This fixes #1315 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d1b2b25 commit 2ff3f70

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

diff.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3791,6 +3791,10 @@ static void run_external_diff(const char *pgm,
37913791
argv_array_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter);
37923792
argv_array_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr);
37933793

3794+
if (one && one->should_munmap)
3795+
diff_free_filespec_data(one);
3796+
if (two && two->should_munmap)
3797+
diff_free_filespec_data(two);
37943798
if (run_command_v_opt_cd_env(argv.argv, RUN_USING_SHELL, NULL, env.argv))
37953799
die(_("external diff died, stopping at %s"), name);
37963800

0 commit comments

Comments
 (0)