有没有一种方法可以按给定模式显示经过git-diff筛选的内容?
类似于:
但愿能找到一个命令来实现这个功能。
类似于:
git grepdiff pattern
changed file
+++ some sentence with pattern
changed file 2
--- some other pattern
不幸的是,最简单的解决方案并不够好。
git diff | grep pattern
+++ some sentence with pattern
--- some other pattern
# not an option as doesn't put the filename close to the match
我使用awk提出了一个解决方案
git diff | awk "/\+\+\+/{f = \$2}; /PATTERN/ {print f \$0} "
但愿能找到一个命令来实现这个功能。