I have set Git's pager option to this
[pager]
log = diff-highlight
I downloaded the diff-highlight
script from Git's repository 3dbfe2b8
and placed it in my ~/bin
folder.
$ where git
C:\Program Files\Git\cmd\git.exe
$ where diff-highlight
C:\Users\andy\bin\diff-highlight
Running git log
results in the following error:
$ git log
Can't open diff-highlight: No such file or directory at C:\Users\andy\bin\diff-highlight line 36.
Segmentation fault
On the other hand, the following command runs just fine,
$ git log -p --color | diff-highlight | less -FRSX
This means diff-highlight
is available from $PATH
, but Git's config cannot find it.
My Git version is 2.12.0.windows.1
.
Recent guidance suggests putting the whole diff-highlight | less -FRSX
diff-highlight | less -FRSX
string into the pager.XXX
config.
This works just fine for me with a Make
d version of the current diff-highlight
script, although I only use it for pager.diff
and interactive.diffFilter
.
The Segmentation fault
part should, at least, disappear: When a non-existent program is given as the pager, we tried to reuse an uninitialized child_process
structure and crashed, which has been fixed with Git 2.35 (Q1 2022).
See commit f917f57 (24 Nov 2021) by Enzo Matsumiya ( ematsumiya
) .
(Merged by Junio C Hamano -- gitster
-- in commit bb47eee , 10 Dec 2021)
pager
: fix crash when pager program doesn't existSigned-off-by: Enzo Matsumiya
When
prepare_cmd()
fails for, eg, pager process setup,child_process_clear()
frees the memory inpager_process
.args, but .argv was pointed topager_process
.args.v earlier instart_command()
, so it's now a dangling pointer.
setup_pager()
is then called a second time, fromcmd_log_init_finish()
in this case, and any further operations using its .argv, egstrvec_*,
will use the dangling pointer and eventually crash.
According to trivial tests,setup_pager()
is not called twice if the first call is successful.This patch makes sure that
pager_process
is properly initialized onsetup_pager()
.
DropCHILD_PROCESS_INIT
from its declaration since it's no longer really necessary.Add a test to catch possible regressions.
Reproducer:
$ git config pager.show INVALID_PAGER $ git show $VALID_COMMIT error: cannot run INVALID_PAGER: No such file or directory [1] 3619 segmentation fault (core dumped) git show $VALID_COMMIT
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.