Re: [PATCH v2 1/1] diff: munmap() file contents before running external diff
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 11, 2019, 19:03 UTC
- Message-ID
- <xmqq36jcs8b8.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <8a0213291b2afc8db9243808319dc86b736122c8.1562833419.git.gitgitgadget@gmail.com>
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 33 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> 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>
> ---
> diff.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/diff.c b/diff.c
> index 4d3cf83a27..42affb6dcf 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -4206,6 +4206,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);Looks sensible; will queue. Thanks.