[英]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.diff
和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). 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 existpager
:当寻呼机程序不存在时修复崩溃Signed-off-by: Enzo Matsumiya
签字人: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.当
prepare_cmd()
失败时,例如,pager 进程设置,child_process_clear()
释放pager_process
.args 中的内存,但 .argv 之前在start_command()
指向pager_process
.args.v,所以它现在是一个悬空指针。
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.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 onsetup_pager()
.此补丁确保
pager_process
在setup_pager()
上正确初始化。
DropCHILD_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.