Skip to content

Commit 353cde2

Browse files
dschojamill
authored andcommitted
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 git-for-windows#1315 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 5bc87a0 commit 353cde2

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
@@ -4092,6 +4092,10 @@ static void run_external_diff(const char *pgm,
40924092
argv_array_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter);
40934093
argv_array_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr);
40944094

4095+
if (one && one->should_munmap)
4096+
diff_free_filespec_data(one);
4097+
if (two && two->should_munmap)
4098+
diff_free_filespec_data(two);
40954099
if (run_command_v_opt_cd_env(argv.argv, RUN_USING_SHELL, NULL, env.argv))
40964100
die(_("external diff died, stopping at %s"), name);
40974101

0 commit comments

Comments
 (0)