R.A. Epigonos et al.

[git] 自分がコミットしたファイルのリスト

以下のようにする。git log で自分 (git config user.email で自分がコミットする際の mail アドレス) が auther に含まれるコミットを抽出してコミットハッシュ %H を標準出力、git-show --name-only でこれらのハッシュで変更されたファイル名を標準出力、grep -v -e '^$' で空行を削除して、sort -u で重複行を削除する。上の例では author に自分が通常コミットする際に使われるメールアドレスを渡しているけど、適当に名前を変えれば任意の人で絞り込みができる。

$ git log --author=$(git config user.email) --pretty=format:%H | xargs -r git show --name-only --pretty=format: | grep -v -e '^$' | sort -u

最終的に渡されるのはファイル名のリストなので、grep に渡して copyright 行だけを抽出したり必要な処理を行う。現在のワーキングツリーの状態では存在しないファイルも出てくることがたまに問題になる。これを避けるために以下の例では grep -sとしてファイルが存在しない場合のエラーメッセージを見えないようにしている。

$ git log --author=$(git config user.email) --pretty=format:%H | xargs -r git show --name-only --pretty=format: | grep -v -e '^$' | sort -u | xargs -r grep -sH -e 'Copyright'
doc/ja/CMakeLists.txt:# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
doc/ja/Makefile.am:# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
doc/ja/weechat_dev.ja.asciidoc: * Copyright (C) 2015 Your Name <your@email.com>
po/CMakeLists.txt:# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
po/ja.po:# Copyright (C) 2012-2015 Ryuunosuke Ayanokouzi <i38w7i3@yahoo.co.jp>
po/ja.po:"WeeChat %s Copyright %s, compiled on %s %s\n"
src/gui/gui-chat.c: * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2008-09-04T10:09:30+09:00
  2. Modified: 2008-09-04T10:09:30+09:00
  3. Generated: 2023-08-27T23:09:17+09:00