YAMAGUCHI::weblog

海水パンツとゴーグルで、巨万の富を築きました。カリブの怪物、フリーアルバイター瞳です。

特定のコミットメッセージを持つコミットの詳細なコミットログを一覧で見る

はじめに

こんにちは、Stackdriver担当者です。いまGoのコミットを調査していて必要になったので調べていました。

ユースケース

Go本体にコントリビュートする場合、コミットメッセージの形式が次のように定められています。

math: improve Sin, Cos and Tan precision for very large arguments

The existing implementation has poor numerical properties for
large arguments, so use the McGillicutty algorithm to improve
accuracy above 1e10.

The algorithm is described at https://wikipedia.org/wiki/McGillicutty_Algorithm

Fixes #159

最初の行では変更を加えたパッケージ名をまず書いた後に、コロンを挟んで1行でコミット内容を説明します。空行を挟んで、2パラグラフめ以降に詳細なコミットメッセージを書いていくわけです。

今回、cmd/compile パッケージに加えられたコミットのコミットメッセージをすべてみたいという要求があり、結果次のようにして一覧しました。

% git log --oneline --grep "cmd/compile" | cut -f 1 -d ' ' | xargs git show --abbrev-commit --quiet

この様に表示されます。

% git log --oneline --grep "cmd/compile" | cut -f 1 -d ' ' | xargs git show --abbrev-commit --quiet
commit fbde753a58
Author: Keith Randall <keithr@alum.mit.edu>
Date:   Tue Jun 25 22:24:34 2019 -0400

    cmd/compile: make duplicate anonymous interface output deterministic
    
    Taking over CL 162240, the original CL hasn't been making progress.
    I just took the parts that fix the immediate issue. I left the
    signatslice changes out, I don't think they are necessary.
    
    Fixes #30202
    
    Change-Id: I5b347605f0841dd925d5a73150b8bf269fa82464
    Reviewed-on: https://go-review.googlesource.com/c/go/+/183852
    Run-TryBot: Keith Randall <khr@golang.org>
    Reviewed-by: David Chase <drchase@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>

commit 4ea7aa7cf3
Author: Cherry Zhang <cherryyz@google.com>
Date:   Tue Jun 25 14:48:04 2019 -0400

    cmd/compile, runtime: use R20, R21 in ARM64's Duff's devices
    
    Currently we use R16 and R17 for ARM64's Duff's devices.
    According to ARM64 ABI, R16 and R17 can be used by the (external)
    linker as scratch registers in trampolines. So don't use these
    registers to pass information across functions.
    
    It seems unlikely that calling Duff's devices would need a
    trampoline in normal cases. But it could happen if the call
    target is out of the 128 MB direct jump limit.
...

他にもっといい方法があったら教えてください。

追記 (2019.07.08 19:00)

いくつか助言をいただいたので、その後諸々検討してみました

% git log --oneline src/cmd/compile | wc -l
3951

% git log --oneline --grep "cmd/compile" src/cmd/compile | wc -l
3673

% git log --oneline src/cmd/compile | grep "cmd/compile" | wc -l
3654

% git log --oneline --grep "^cmd/compile" src/cmd/compile | wc -l
3080

この中でどれが自分の本当に求めているログに絞れているのかと考えてみると、おそらく3番目のもので、理由は

  1. Goのコミットメッセージの規約は守られていると仮定して、--grep="cmd/compile" としてしまうと、2パラグラフめ以降にだけ cmd/compile が入っているものが含まれてしまう。
  2. "^cmd/compile" としてしまうと、1行目の対象パッケージの部分で、 runtime, cmd/compile: となっているようなコミットが漏れてしまう。

が挙げられる。したがって今回自分がみたいログを見ようと思ったら

% git log --oneline src/cmd/compile | grep "cmd/compile" | xargs git show --abbrev-commit --quiet

が正解になると思う。