It has been pointed out in 2016 by Andrew Cuthbert that git diff
locks files as well until you quit out of it.
That won't be the case with Git 2.23 (Q3 2019).
See commit 3aef54e (11 Jul 2019) by Johannes Schindelin (dscho
).
(Merged by Junio C Hamano -- gitster
-- in commit d9beb46, 25 Jul 2019)
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 git-for-windows#1315
Running "git diff
"(man) while allowing external diff in a state with unmerged paths used to segfault, which has been corrected with Git 2.30 (Q1 2021).
See commit d668518, commit 2469593 (06 Nov 2020) by Jinoh Kang (iamahuman
).
(Merged by Junio C Hamano -- gitster
-- in commit d5e3532, 21 Nov 2020)
diff
: allow passing NULL
to diff_free_filespec_data()
Signed-off-by: Jinoh Kang
Signed-off-by: Junio C Hamano
Commit 3aef54e8b8 ("diff
: munmap()
file contents before running external diff", Git v2.22.1) introduced calls to diff_free_filespec_data
in run_external_diff,
which may pass NULL
pointers.
Fix this and prevent any such bugs in the future by making diff_free_filespec_data(NULL)
a no-op.
Fixes: 3aef54e8b8 ("diff: munmap() file contents before running external diff")