summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorLibravatar Johannes Schindelin <johannes.schindelin@gmx.de>2019-07-11 01:23:41 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-07-11 12:11:54 -0700
commit3aef54e8b82bc02b9cebbb7d0bed8911ee0418e3 (patch)
tree1735641d6a46d1a8e1f1903bc64f3452527bd8e4 /diff.c
parentmingw: allow building with an MSYS2 runtime v3.x (diff)
downloadtgif-3aef54e8b82bc02b9cebbb7d0bed8911ee0418e3.tar.xz
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 https://github.com/git-for-windows/git/issues/1315 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/diff.c b/diff.c
index 5306c48652..0d2b287300 100644
--- a/diff.c
+++ b/diff.c
@@ -4207,6 +4207,8 @@ static void run_external_diff(const char *pgm,
argv_array_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter);
argv_array_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr);
+ diff_free_filespec_data(one);
+ diff_free_filespec_data(two);
if (run_command_v_opt_cd_env(argv.argv, RUN_USING_SHELL, NULL, env.argv))
die(_("external diff died, stopping at %s"), name);