How to make 'git diff' ignore comments

前端 未结 6 1477
闹比i
闹比i 2020-12-05 02:38

I am trying to produce a list of the files that were changed in a specific commit. The problem is, that every file has the version number in a comment at the top of the file

6条回答
  •  抹茶落季
    2020-12-05 03:17

    Perhaps a Bash script like this:

    #!/bin/bash
    git diff --name-only "$@" | while read FPATH ; do
        LINES_COUNT=`git diff --textconv "$FPATH" "$@" | sed '/^[1-]\s\+[1-]\s\+.*/d' | wc -l`
        if [ $LINES_COUNT -gt 0 ] ; then
            echo -e "$LINES_COUNT\t$FPATH"
        fi
    done | sort -n
    

提交回复
热议问题