1

以前のコミットの git リポジトリから新しく追加、変更、および削除された行の行番号を取得しようとしています。以下のbash関数を使用して作業を完了しています。しかし、パス値を取得できず (null が表示されています)、行番号も期待どおりではありません。以下の出力を確認してください。

diff-lines() {
        local path=
        local line=
        while read; do
            esc=$'\033'
            if [[ $REPLY =~ ---\ (a/)?.* ]]; then
                continue
            elif [[ $REPLY =~ \+\+\+\ (b/)?([^[:blank:]$esc]+).* ]]; then
                path=${BASH_REMATCH[2]}
            elif [[ $REPLY =~ @@\ -[0-9]+(,[0-9]+)?\ \+([0-9]+)(,[0-9]+)?\ @@.*]]; then
                line=${BASH_REMATCH[2]}
            elif [[ $REPLY =~ ^($esc\[[0-9;]+m)*([\ +-]) ]]; then
                echo "$path:$line:$REPLY"
                if [[ ${BASH_REMATCH[2]} != - ]]; then
                    ((line++))
                fi
            fi
        done
    }

スクリプトを実行すると出力が低下します

    $ git diff -U0 | diff-lines
    ::+++ b/shipserv/shipserv.cpp
    :1:-
    :1:-// check command-line args
    :1:+// check command-line argsss
    :2:+++ b/shipserv/shipserv_client.cpp
    :3:-// #include <infra/utility/environment/config/PimpConfig.h>
    :3:+// #include <nfra/utility/environment/config/PimpConfig.h>
    :4:+++ b/shipserv/test.text
    :5:-dfssdfsdfsdfsf
    :5:+dfssdfsdfsdfsfZZZZZZZZZZZZZZ
    :6:+modified linsde 9898989
    :7:+New line added

誰でもこの問題について私を助けてくれませんか。

4

1 に答える 1

1

のようなものgit log -n 1 --stat、おそらく?私のレポで:

commit 0e35181e68f628234c53347c00a75d7af37bb45e
Author: Horst H. von Brand <vonbrand@example.com>
Date:   Thu Jan 17 15:46:32 2013 -0300

    The proper bibliography key is oliveiraXXX..., add latest results

    Signed-off-by: Horst H. von Brand <vonbrand@example.com>

 logica.tex | 16 +++++++++++++---
 url.bib    | 45 +++++++++++++++++++++++++++------------------
 2 files changed, 40 insertions(+), 21 deletions(-)
于 2013-02-27T20:24:59.727 に答える