我在一個bash命令中查找來自舊SVN存儲庫的Git提交。這裏是我的整個命令:xargs和git log --grep
$ svn log --xml --revision 323016 http://svn.php.net/repository | grep "<msg>" | sed 's/<msg>//' | xargs --verbose -i% git log --pretty=oneline --grep=\"%\"
git log --pretty=oneline --grep="Always restore PG(magic_quote_gpc) on request shutdown"
運行命令的前幾個部分讓我提交評論:
$ svn log --xml --revision 323016 http://svn.php.net/repository | grep "<msg>" | sed 's/<msg>//'
Always restore PG(magic_quote_gpc) on request shutdown
使工作正常 - 但後來當我想使用git登錄--grep通過xargs,它不起作用(不給我答覆)。
這是奇怪的部分... --verbose
打印出我的命令。如果我複製並粘貼那個確切的命令,我得到我需要的輸出。那就是:
$ git log --pretty=oneline --grep="Always restore PG(magic_quote_gpc) on request shutdown"
87c038be06b8b0eb721270f98c858fd701f5d54b Always restore PG(magic_quote_gpc) on request shutdown
而且,這並不能出於某種原因:
$ echo -n "Always restore PG(magic_quote_gpc) on request shutdown" | xargs --verbose -i% git log --grep=\"%\"
git log --grep="Always restore PG(magic_quote_gpc) on request shutdown"
所以這一定是我的xargs使用,對不對?