Skip to content

Commit

Permalink
diff: munmap() file contents before running external diff
Browse files Browse the repository at this point in the history
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 <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Oct 5, 2017
1 parent dc85205 commit 327fab0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions diff.c
Expand Up @@ -3094,6 +3094,10 @@ 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);

if (one->should_munmap)
diff_free_filespec_data(one);
if (two->should_munmap)
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);

Expand Down

0 comments on commit 327fab0

Please sign in to comment.