Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-06

help with grep search string

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I want to try and improve the IDE to detect SVN or Git repositories, and still extract the correct latest revision number. I have the following output which is part of the commit message generated by Git, when it syncs with a SubVersion repository.

I'm trying to write a grep command that will extract the revision number only. eg:
16557
16556
16555
...

Can anybody help me please? I wrote the following which asks git to only output commit messages containing "git-svn-id", then I run that through standard grep extracting only the line containing the search string. It's this latter part that I want to fix to only return the revision number.

Any help would be greatly appreciated.

$ git log --grep="git-svn-id:" | grep git-svn-id

============ Sample output ===================
git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16557 4005530d-fff6-0310-9dd1-cebe43e6787f git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16556 4005530d-fff6-0310-9dd1-cebe43e6787f git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16555 4005530d-fff6-0310-9dd1-cebe43e6787f git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16554 4005530d-fff6-0310-9dd1-cebe43e6787f git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16553 4005530d-fff6-0310-9dd1-cebe43e6787f git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16552 4005530d-fff6-0310-9dd1-cebe43e6787f

=======================================

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Marc Santhoff
to Graeme Geldenhuys
Graeme Geldenhuys wrote 27 lines
Hi, I want to try and improve the IDE to detect SVN or Git repositories, and still extract the correct latest revision number. I have the following output which is part of the commit message generated by Git, when it syncs with a SubVersion repository. I'm trying to write a grep command that will extract the revision number only. eg: 16557 16556 16555 ... Can anybody help me please? I wrote the following which asks git to only output commit messages containing "git-svn-id", then I run that through standard grep extracting only the line containing the search string. It's this latter part that I want to fix to only return the revision number. Any help would be greatly appreciated. $ git log --grep="git-svn-id:" | grep git-svn-id ============ Sample output =================== git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16557 4005530d-fff6-0310-9dd1-cebe43e6787f git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16556 4005530d-fff6-0310-9dd1-cebe43e6787f git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16555 4005530d-fff6-0310-9dd1-cebe43e6787f git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16554 4005530d-fff6-0310-9dd1-cebe43e6787f git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16553 4005530d-fff6-0310-9dd1-cebe43e6787f git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk at 16552 4005530d-fff6-0310-9dd1-cebe43e6787f =======================================

try:
| awk -F@ '{split($2, x, " "); print x[1]}'

HTH,

Marc Santhoff

Reply by email