Note that there are some explanatory texts on larger screens.

plurals
  1. POpreg_match_all with git log --pretty=raw --all
    primarykey
    data
    text
    <p>I'm trying to use <code>preg_match_all</code> to process the log from <code>git log --pretty=raw --all</code>.</p> <p>The sample data I got is something like this:</p> <pre><code>commit 5650c7841f72c4c65689b0d4bc83ccd70e5b2362 (HEAD, origin/master, origin/HEAD, master) tree 69c6036c64c805e9c335b2eadd87b43af90ee1ad parent a912fdd530efe69dae4b0f417c8a8631d68f469c parent 113e128efe54511f2b0bdd589301ffe039fc185e author Author Name 3 &lt;author.name.3@gmail.com&gt; 1371835063 -0700 committer Committer Name 3 &lt;committer.name.3@gmail.com&gt; 1371835063 -0700 Merge pull request #60 from sample/master Line 2 message commit 94e99889226671dc479be770968df2692e09db11 (origin/fixit) tree f900c172fa633b3769b982614ce639e3ee6f3b62 parent dc56687f1597b317064b0d899c2450fb6805791e author Author Name 2 &lt;author.name.2@something.com.tld&gt; 1370944188 +0300 committer Committer Name 2 &lt;committer.name.2@something.com.tld&gt; 1370944188 +0300 1 line message commit dc56687f1597b317064b0d899c2450fb6805791e tree cb1573ccde7ddcb2e54b9b9a777e11a435d532ac parent a912fdd530efe69dae4b0f417c8a8631d68f469c author Author Name 1 &lt;author.name.1@gmail.com&gt; 1370640640 +0300 committer Committer Name 1 &lt;committer.name.1@gmail.com&gt; 1370943413 +0300 Message contain words like commit tree parent author committer to screw your regex. Also contain other symbols like @ # ! % ( ) = - | Can you handle 2nd paragraph? 3rd paragraph? </code></pre> <p>`</p> <p>I would like to extract the</p> <ul> <li>commit hash</li> <li>tree hash</li> <li>parents hash</li> <li>author name</li> <li>commiter, and </li> <li>commit message</li> </ul> <p>The closest I can get is with:</p> <p><code>/^commit (.{40})(.*)\s^tree (.{40})\s^parent (.{40})\s(^parent (.{40})\s)?^author (.+)\s^committer (.+)\s+(.+)\s+/m</code></p> <p>Which come out something like this: <a href="http://regex101.com/r/cY4qV4" rel="nofollow">http://regex101.com/r/cY4qV4</a></p> <p>Is there more accurate regex for above data that don't break easily like mine?</p> <p>Something to take note:</p> <ol> <li>tags, branches in () after commit (additional question: Is it possible to separate tag/branch by comma (,) also within 1 regex?)</li> <li>some commit has 2 parents</li> <li>commit message may contains multiple paragraph, weird symbols or words that you use in regex</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload