Filtering a diff with a regular expression

前端 未结 7 1209
逝去的感伤
逝去的感伤 2020-12-01 21:30

It seems that it would be extremely handy to be able to filter a diff so that trivial changes are not displayed. I would like to write a regular expression which would be ru

7条回答
  •  Happy的楠姐
    2020-12-01 21:51

    $ git diff --help
    
    -G
        Look for differences whose added or removed line matches the given .
    

    EDIT:

    After some tests I've got something like

    git diff -b -w --word-diff-regex='.*\[[^"]*\]'
    

    Then I've got output like:

    diff --git a/test.php b/test.php
    index 62a2de0..b76891f 100644
    --- a/test.php
    +++ b/test.php
    @@ -1,3 +1,5 @@
    
    diff --git a/test1.php b/test1.php
    index 62a2de0..6102fed 100644
    --- a/test1.php
    +++ b/test1.php
    @@ -1,3 +1,5 @@
    
    

    Maybe it will help you. I found it here http://www.rhinocerus.net/forum/lang-lisp/659593-git-word-diff-regex-lisp-source.html and there is more information on this thread

    EDIT2:

    git diff -G'\[[A-Za-z_]*\]' --pickaxe-regex
    

提交回复
热议问题