Reputation: 1493
Currently, I am working on mining software repository in github
. I use the git log command
to get the commit logs. But when I only need to find the commit logs contain a specific word, some unexpected logs also have shown.
For example, I need the commit log contains word HBASE-792
. I used command git log --grep='HBASE-792' --oneline
. But these logs have shown:
HBASE-7921. TestHFileBlock.testGzipCompression should ignore the block checksum
HBASE-7923 force unassign can confirm region online on any RS to get rid of double assignments
HBASE-7928 Scanning .META. with startRow and/or stopRow is not giving proper results; REVERT. NEEDS SOME MORE WORK
Fix overlogging; part of HBASE-792 patch
Patches to alleviate HBASE-790 and HBASE-792
What I need are only the last 2 commit logs which exactly contain HBASE-792
. What pattern should I write in grep?
Upvotes: 0
Views: 2109
Reputation: 76907
You can try piping the output of git log to grep, and using the -w
flag of grep. Here go the sample run for a test repo I made:
Test $ git log --grep='HBASE-792' --oneline
09172fd asd sHBASE-792 asd
bea6628 asd HBASE-792s asd
3100179 asd HBASE-792 asd
4cb3200 HBASE-792
with -w
flag:
Test $ git log --oneline | grep -w "HBASE-792"
3100179 asd HBASE-792 asd
4cb3200 HBASE-792
Upvotes: 2
Reputation: 521419
You could try running the grep in Perl mode:
git log --grep='\bHBASE-792\b' --perl-regexp --oneline
All I did was to put word boundaries around HBASE-792
. With them in place, your pattern should no longer match to e.g. HBASE-7923
which appears at the start of one of the lines which should not match.
Upvotes: 2