ydiff: side-by-side, character-level diffs in the terminal

栏目: IT技术 · 发布时间: 5年前

内容简介:This isIt's been heavily modified and stripped down to a very specific feature subset:And, modified to be visually less noisy.

joshuarli's ydiff fork

This is ydiff , distilled down to the very core.

It's been heavily modified and stripped down to a very specific feature subset:

  • py3.6+
  • assumes utf-8
  • only read git unified diffs from stdin
  • only side-by-side rendering

And, modified to be visually less noisy.

Screenshots

Here's what it looks like:

ydiff: side-by-side, character-level diffs in the terminal

Compared to before (the automatic width detection failed lol):

ydiff: side-by-side, character-level diffs in the terminal

Performance

I'm definitely not smart enough to port it to more performant languages, but I've made it quite fast:

$ git log --patch | pv > /tmp/sentry-git-log
... 17.4MiB/s ...
-rw-r--r-- 1 josh josh 573M Jun 27 00:00 /tmp/sentry-git-log

$ ./ymattw-ydiff.py --wrap --side-by-side --color=always --pager=cat \
    < /tmp/sentry-git-log | pv >/dev/null

... 761KiB/s ...

$ ./ydiff < /tmp/sentry-git-log | pv >/dev/null

... 1.37MiB/s ...

I've also optimized it to build as a relatively clean Cython binary, which runs a bit faster but more importantly is faster to start up:

$ ./ydiff-bin < /tmp/sentry-git-log | pv >/dev/null
... 1.60MiB/s ...

$ hyperfine --warmup 3 "./ydiff < tests/sentry/1/in.diff >/dev/null"
Benchmark #1: ./ydiff < tests/sentry/1/in.diff >/dev/null
  Time (mean ± σ):     115.3 ms ±   2.3 ms    [User: 53.1 ms, System: 43.4 ms]
  Range (min … max):   112.5 ms … 123.7 ms    24 runs

$ hyperfine --warmup 3 "./ydiff-bin < tests/sentry/1/in.diff >/dev/null"
Benchmark #1: ./ydiff-bin < tests/sentry/1/in.diff >/dev/null
  Time (mean ± σ):      35.8 ms ±   1.9 ms    [User: 26.3 ms, System: 7.8 ms]
  Range (min … max):    32.8 ms …  40.2 ms    74 runs

Installation

Just download this to anywhere on your PATH, then set the following git config:

git config --global pager.diff "ydiff | less"
git config --global pager.show "ydiff | less"
git config --global pager.log less
git config --global color.diff never

I also recommend setting LESS=FSXR . less will use those flags by default. You could alternatively put those in your git config.

Optionally, if you have a C compiler, you can compile the Cython binary with make ydiff-bin .


以上所述就是小编给大家介绍的《ydiff: side-by-side, character-level diffs in the terminal》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

高性能MySQL

高性能MySQL

施瓦茨 (Baron Schwartz)、扎伊采夫 (Peter Zaitsev)、特卡琴科 (Vadim Tkachenko) / 宁海元、周振兴、彭立勋、翟卫祥,刘辉 / 电子工业出版社 / 2013-5-1 / 128.00元

《高性能mysql(第3版)》是mysql 领域的经典之作,拥有广泛的影响力。第3 版更新了大量的内容,不但涵盖了最新mysql 5.5版本的新特性,也讲述了关于固态盘、高可扩展性设计和云计算环境下的数据库相关的新内容,原有的基准测试和性能优化部分也做了大量的扩展和补充。全书共分为16 章和6 个附录,内容涵盖mysql 架构和历史,基准测试和性能剖析,数据库软硬件性能优化,复制、备份和恢复,高可......一起来看看 《高性能MySQL》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具