简体   繁体   English

设置为差异突出显示的 Git 寻呼机在 Windows 10 中不起作用

[英]Git pager set to diff-highlight does not work in Windows 10

I have set Git's pager option to this我已将 Git 的寻呼机选项设置为此

[pager]
    log = diff-highlight 

I downloaded the diff-highlight script from Git's repository 3dbfe2b8 and placed it in my ~/bin folder.我从Git 的存储库3dbfe2b8下载了diff-highlight脚本并将其放在我的~/bin文件夹中。

$ 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导致以下错误:

$ 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.这意味着diff-highlight可从$PATH ,但 Git 的配置找不到它。

My Git version is 2.12.0.windows.1 .我的 Git 版本是2.12.0.windows.1

Recent guidance suggests putting the whole diff-highlight | less -FRSX 最近的指导意见建议整个diff-highlight | less -FRSX diff-highlight | less -FRSX string into the pager.XXX config. diff-highlight | less -FRSX字符串进入pager.XXX配置。

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 . 使用当前diff-highlight脚本的Make d版本,这对我来说效果很好,尽管我只将它用于pager.diffinteractive.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). Segmentation fault部分至少应该消失:当一个不存在的程序作为寻呼机时,我们试图重用一个未初始化的child_process结构并崩溃,这已在 Git 2.35(2022 年第一季度)中修复。

See commit f917f57 (24 Nov 2021) by Enzo Matsumiya ( ematsumiya ) .请参阅Enzo Matsumiya ( ematsumiya ) 提交的 f917f57 (2021 年 11 月 24 日)
(Merged by Junio C Hamano -- gitster -- in commit bb47eee , 10 Dec 2021) (由Junio C gitster -- gitster --提交 bb47eee 中合并,2021 年 12 月 10 日)

pager : fix crash when pager program doesn't exist pager :当寻呼机程序不存在时修复崩溃

Signed-off-by: Enzo Matsumiya签字人:Enzo Matsumiya

When prepare_cmd() fails for, eg, pager process setup, child_process_clear() frees the memory in pager_process .args, but .argv was pointed to pager_process .args.v earlier in start_command() , so it's now a dangling pointer.prepare_cmd()失败时,例如,pager 进程设置, child_process_clear()释放pager_process .args 中的内存,但 .argv 之前在start_command()指向pager_process .args.v,所以它现在是一个悬空指针。

setup_pager() is then called a second time, from cmd_log_init_finish() in this case, and any further operations using its .argv, eg strvec_*, will use the dangling pointer and eventually crash. setup_pager()然后被称为第二次,从cmd_log_init_finish()在这种情况下,并使用其.argv任何进一步的操作,例如strvec_*,将使用悬挂指针,并最终崩溃。
According to trivial tests, setup_pager() is not called twice if the first call is successful.根据简单的测试,如果第一次调用成功, setup_pager()不会被调用两次。

This patch makes sure that pager_process is properly initialized on setup_pager() .此补丁确保pager_processsetup_pager()上正确初始化。
Drop CHILD_PROCESS_INIT from its declaration since it's no longer really necessary.从声明中删除CHILD_PROCESS_INIT ,因为它不再是真正必要的。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM