<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Wt examples: Git Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Wt examples  <span id="projectnumber">3.2.3</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.5.1 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="inherits.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#nested-classes">Classes</a> | <a href="#pub-types">Public Types</a> | <a href="#pub-methods">Public Member Functions</a> | <a href="#pri-methods">Private Member Functions</a> | <a href="#pri-attribs">Private Attributes</a> </div> <div class="headertitle"> <div class="title">Git Class Reference<div class="ingroups"><a class="el" href="group__gitmodelexample.html">Git model example</a></div></div> </div> </div> <div class="contents"> <!-- doxytag: class="Git" --> <p>Git utility class for browsing git archives. <a href="classGit.html#details">More...</a></p> <p><code>#include <<a class="el" href="Git_8h_source.html">Git.h</a>></code></p> <p><a href="classGit-members.html">List of all members.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="nested-classes"></a> Classes</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit_1_1Exception.html">Exception</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Exception class. <a href="classGit_1_1Exception.html#details">More...</a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structGit_1_1Object.html">Object</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Git object. <a href="structGit_1_1Object.html#details">More...</a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit_1_1ObjectId.html">ObjectId</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Git object Id. <a href="classGit_1_1ObjectId.html#details">More...</a><br/></td></tr> <tr><td colspan="2"><h2><a name="pub-types"></a> Public Types</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#ab282f46c36a47ddff9bc7be7c993041a">ObjectType</a> { <a class="el" href="classGit.html#ab282f46c36a47ddff9bc7be7c993041aae94d3a7ff6594f6b3b0dc121fbd01564">Tree</a>, <a class="el" href="classGit.html#ab282f46c36a47ddff9bc7be7c993041aa5952f4b5af05765dda2c75c09a1370b6">Commit</a>, <a class="el" href="classGit.html#ab282f46c36a47ddff9bc7be7c993041aa64c3a7b641cdc0cb2c4203fc0bef1a4a">Blob</a> }</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Git object type. <a href="classGit.html#ab282f46c36a47ddff9bc7be7c993041a">More...</a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">typedef std::list< std::pair<br class="typebreak"/> < std::string, std::string > > </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#a23da7b806839f7a482935a44142b04c9">Cache</a></td></tr> <tr><td colspan="2"><h2><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#afdc93b8c52e55a1977c9333d71561cd5">Git</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <a href="#afdc93b8c52e55a1977c9333d71561cd5"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#ab21f8d442557b07321a274b5e976f1ac">setRepositoryPath</a> (const std::string &repository)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Set the git repository path. <a href="#ab21f8d442557b07321a274b5e976f1ac"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGit_1_1ObjectId.html">ObjectId</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#a521bba51875ea14c9e39a14fcde01e04">getCommitTree</a> (const std::string &revision) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Get the tree for a particular revision. <a href="#a521bba51875ea14c9e39a14fcde01e04"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGit_1_1ObjectId.html">ObjectId</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#ab432b071c7d22343a7ac136c35230251">getCommit</a> (const std::string &revision) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Get the commit for a particular revision. <a href="#ab432b071c7d22343a7ac136c35230251"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGit_1_1ObjectId.html">ObjectId</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#a62bf9de2511aeb8e036a339ec8be8423">getTreeFromCommit</a> (const <a class="el" href="classGit_1_1ObjectId.html">ObjectId</a> &commit) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Get the tree for a particular commit. <a href="#a62bf9de2511aeb8e036a339ec8be8423"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structGit_1_1Object.html">Object</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#a910f3a6123b494897cdedf7ba4ef648b">treeGetObject</a> (const <a class="el" href="classGit_1_1ObjectId.html">ObjectId</a> &tree, int index) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Get some info on a tree object. <a href="#a910f3a6123b494897cdedf7ba4ef648b"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#abe86381afbbab0adb0680ae268752f1f">treeSize</a> (const <a class="el" href="classGit_1_1ObjectId.html">ObjectId</a> &tree) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Return the number of objects inside a tree object. <a href="#abe86381afbbab0adb0680ae268752f1f"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#acf2d699d9f9bdfb42afb0f61e85b2f88">catFile</a> (const <a class="el" href="classGit_1_1ObjectId.html">ObjectId</a> &id) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Return the raw contents of a git object. <a href="#acf2d699d9f9bdfb42afb0f61e85b2f88"></a><br/></td></tr> <tr><td colspan="2"><h2><a name="pri-methods"></a> Private Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#a04766dfcc9edcae7c12e6ff373176c7c">checkRepository</a> () const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Checks the repository. <a href="#a04766dfcc9edcae7c12e6ff373176c7c"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#a3dccd1727396de007ec5b43e96930a1b">getCmdResult</a> (const std::string &cmd, std::string &result, const std::string &tag) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns a line identified by a tag from the output of a git command. <a href="#a3dccd1727396de007ec5b43e96930a1b"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#a5c0f41b8540cae5aef55343dcbbbf8b6">getCmdResult</a> (const std::string &cmd, std::string &result, int index) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the <em>i</em>th line from the output of a git command. <a href="#a5c0f41b8540cae5aef55343dcbbbf8b6"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#a451e493481c2b397497107a6e60a6360">getCmdResultLineCount</a> (const std::string &cmd) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the number of lines in the output of a git command. <a href="#a451e493481c2b397497107a6e60a6360"></a><br/></td></tr> <tr><td colspan="2"><h2><a name="pri-attribs"></a> Private Attributes</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#a5f478cb0fb21487e60f87b93d4277440">repository_</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">The path to the repository. <a href="#a5f478cb0fb21487e60f87b93d4277440"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGit.html#a23da7b806839f7a482935a44142b04c9">Cache</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGit.html#a0097b8efc1e8530cc11133622684e9ef">cache_</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">A small LRU cache that stores results of git commands. <a href="#a0097b8efc1e8530cc11133622684e9ef"></a><br/></td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><p>Git utility class for browsing git archives. </p> <p>Far from complete! Only browses git revisions. </p> <p>Definition at line <a class="el" href="Git_8h_source.html#l00023">23</a> of file <a class="el" href="Git_8h_source.html">Git.h</a>.</p> </div><hr/><h2>Member Typedef Documentation</h2> <a class="anchor" id="a23da7b806839f7a482935a44142b04c9"></a><!-- doxytag: member="Git::Cache" ref="a23da7b806839f7a482935a44142b04c9" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">typedef std::list<std::pair<std::string, std::string> > <a class="el" href="classGit.html#a23da7b806839f7a482935a44142b04c9">Git::Cache</a></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="Git_8h_source.html#l00119">119</a> of file <a class="el" href="Git_8h_source.html">Git.h</a>.</p> </div> </div> <hr/><h2>Member Enumeration Documentation</h2> <a class="anchor" id="ab282f46c36a47ddff9bc7be7c993041a"></a><!-- doxytag: member="Git::ObjectType" ref="ab282f46c36a47ddff9bc7be7c993041a" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">enum <a class="el" href="classGit.html#ab282f46c36a47ddff9bc7be7c993041a">Git::ObjectType</a></td> </tr> </table> </div> <div class="memdoc"> <p>Git object type. </p> <dl><dt><b>Enumerator: </b></dt><dd><table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"><em><a class="anchor" id="ab282f46c36a47ddff9bc7be7c993041aae94d3a7ff6594f6b3b0dc121fbd01564"></a><!-- doxytag: member="Tree" ref="ab282f46c36a47ddff9bc7be7c993041aae94d3a7ff6594f6b3b0dc121fbd01564" args="" -->Tree</em> </td><td> </td></tr> <tr><td valign="top"><em><a class="anchor" id="ab282f46c36a47ddff9bc7be7c993041aa5952f4b5af05765dda2c75c09a1370b6"></a><!-- doxytag: member="Commit" ref="ab282f46c36a47ddff9bc7be7c993041aa5952f4b5af05765dda2c75c09a1370b6" args="" -->Commit</em> </td><td> </td></tr> <tr><td valign="top"><em><a class="anchor" id="ab282f46c36a47ddff9bc7be7c993041aa64c3a7b641cdc0cb2c4203fc0bef1a4a"></a><!-- doxytag: member="Blob" ref="ab282f46c36a47ddff9bc7be7c993041aa64c3a7b641cdc0cb2c4203fc0bef1a4a" args="" -->Blob</em> </td><td> </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8h_source.html#l00058">58</a> of file <a class="el" href="Git_8h_source.html">Git.h</a>.</p> <div class="fragment"><pre class="fragment">{ <a class="code" href="classGit.html#ab282f46c36a47ddff9bc7be7c993041aae94d3a7ff6594f6b3b0dc121fbd01564">Tree</a>, <a class="code" href="classGit.html#ab282f46c36a47ddff9bc7be7c993041aa5952f4b5af05765dda2c75c09a1370b6">Commit</a>, <a class="code" href="classGit.html#ab282f46c36a47ddff9bc7be7c993041aa64c3a7b641cdc0cb2c4203fc0bef1a4a">Blob</a> }; </pre></div> </div> </div> <hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="afdc93b8c52e55a1977c9333d71561cd5"></a><!-- doxytag: member="Git::Git" ref="afdc93b8c52e55a1977c9333d71561cd5" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Git::Git </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Constructor. </p> <p>Definition at line <a class="el" href="Git_8C_source.html#l00178">178</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment"> : <a class="code" href="classGit.html#a0097b8efc1e8530cc11133622684e9ef" title="A small LRU cache that stores results of git commands.">cache_</a>(3) <span class="comment">// cache of 3 git results</span> { } </pre></div> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="acf2d699d9f9bdfb42afb0f61e85b2f88"></a><!-- doxytag: member="Git::catFile" ref="acf2d699d9f9bdfb42afb0f61e85b2f88" args="(const ObjectId &id) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">std::string Git::catFile </td> <td>(</td> <td class="paramtype">const <a class="el" href="classGit_1_1ObjectId.html">ObjectId</a> & </td> <td class="paramname"><em>id</em></td><td>)</td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>Return the raw contents of a git object. </p> <dl><dt><b>Exceptions:</b></dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGit_1_1Exception.html" title="Exception class.">Exception</a></td><td>: in case of a git error. </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8C_source.html#l00194">194</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment">{ std::string result; <span class="keywordflow">if</span> (!<a class="code" href="classGit.html#a3dccd1727396de007ec5b43e96930a1b" title="Returns a line identified by a tag from the output of a git command.">getCmdResult</a>(<span class="stringliteral">"cat-file -p "</span> + <span class="keywordtype">id</span>.toString(), result, -1)) <span class="keywordflow">throw</span> Exception(<span class="stringliteral">"Git: could not cat '"</span> + <span class="keywordtype">id</span>.toString() + <span class="stringliteral">"'"</span>); <span class="keywordflow">return</span> result; } </pre></div> </div> </div> <a class="anchor" id="a04766dfcc9edcae7c12e6ff373176c7c"></a><!-- doxytag: member="Git::checkRepository" ref="a04766dfcc9edcae7c12e6ff373176c7c" args="() const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Git::checkRepository </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const<code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Checks the repository. </p> <dl><dt><b>Exceptions:</b></dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGit_1_1Exception.html" title="Exception class.">Exception</a></td><td>: in case the repository is not a valid. </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8C_source.html#l00323">323</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment">{ POpenWrapper p(<span class="stringliteral">"git --git-dir="</span> + <a class="code" href="classGit.html#a5f478cb0fb21487e60f87b93d4277440" title="The path to the repository.">repository_</a> + <span class="stringliteral">" branch"</span>, <a class="code" href="classGit.html#a0097b8efc1e8530cc11133622684e9ef" title="A small LRU cache that stores results of git commands.">cache_</a>); std::string r; <span class="keywordflow">if</span> (p.exitStatus() != 0) <span class="keywordflow">throw</span> Exception(<span class="stringliteral">"Git error: "</span> + p.readLine(r)); } </pre></div> </div> </div> <a class="anchor" id="a3dccd1727396de007ec5b43e96930a1b"></a><!-- doxytag: member="Git::getCmdResult" ref="a3dccd1727396de007ec5b43e96930a1b" args="(const std::string &cmd, std::string &result, const std::string &tag) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool Git::getCmdResult </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"><em>cmd</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">std::string & </td> <td class="paramname"><em>result</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const std::string & </td> <td class="paramname"><em>tag</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td> const<code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns a line identified by a tag from the output of a git command. </p> <p>The line is filled in <em>result</em>. Returns whether a line starting with <em>tag</em> could be found.</p> <dl><dt><b>Exceptions:</b></dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGit_1_1Exception.html" title="Exception class.">Exception</a></td><td>: in case the command failed </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8C_source.html#l00288">288</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment">{ POpenWrapper p(<span class="stringliteral">"git --git-dir="</span> + <a class="code" href="classGit.html#a5f478cb0fb21487e60f87b93d4277440" title="The path to the repository.">repository_</a> + <span class="stringliteral">" "</span> + gitCmd, <a class="code" href="classGit.html#a0097b8efc1e8530cc11133622684e9ef" title="A small LRU cache that stores results of git commands.">cache_</a>); <span class="keywordflow">if</span> (p.exitStatus() != 0) <span class="keywordflow">throw</span> Exception(<span class="stringliteral">"Git error: "</span> + p.readLine(result)); <span class="keywordflow">while</span> (!p.finished()) { p.readLine(result); <span class="keywordflow">if</span> (boost::starts_with(result, tag)) <span class="keywordflow">return</span> <span class="keyword">true</span>; } <span class="keywordflow">return</span> <span class="keyword">false</span>; } </pre></div> </div> </div> <a class="anchor" id="a5c0f41b8540cae5aef55343dcbbbf8b6"></a><!-- doxytag: member="Git::getCmdResult" ref="a5c0f41b8540cae5aef55343dcbbbf8b6" args="(const std::string &cmd, std::string &result, int index) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool Git::getCmdResult </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"><em>cmd</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">std::string & </td> <td class="paramname"><em>result</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>index</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td> const<code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the <em>i</em>th line from the output of a git command. </p> <p>The line is filled in <em>result</em>. Returns the whole git output if <em>index</em> = -1, otherwise the line with line number <em>index</em>.</p> <dl><dt><b>Exceptions:</b></dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGit_1_1Exception.html" title="Exception class.">Exception</a></td><td>: in case the command failed </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8C_source.html#l00265">265</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment">{ POpenWrapper p(<span class="stringliteral">"git --git-dir="</span> + <a class="code" href="classGit.html#a5f478cb0fb21487e60f87b93d4277440" title="The path to the repository.">repository_</a> + <span class="stringliteral">" "</span> + gitCmd, <a class="code" href="classGit.html#a0097b8efc1e8530cc11133622684e9ef" title="A small LRU cache that stores results of git commands.">cache_</a>); <span class="keywordflow">if</span> (p.exitStatus() != 0) <span class="keywordflow">throw</span> Exception(<span class="stringliteral">"Git error: "</span> + p.readLine(result)); <span class="keywordflow">if</span> (index == -1) { result = p.contents(); <span class="keywordflow">return</span> <span class="keyword">true</span>; } <span class="keywordflow">else</span> p.readLine(result); <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < index; ++i) { <span class="keywordflow">if</span> (p.finished()) <span class="keywordflow">return</span> <span class="keyword">false</span>; p.readLine(result); } <span class="keywordflow">return</span> <span class="keyword">true</span>; } </pre></div> </div> </div> <a class="anchor" id="a451e493481c2b397497107a6e60a6360"></a><!-- doxytag: member="Git::getCmdResultLineCount" ref="a451e493481c2b397497107a6e60a6360" args="(const std::string &cmd) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int Git::getCmdResultLineCount </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"><em>cmd</em></td><td>)</td> <td> const<code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the number of lines in the output of a git command. </p> <dl><dt><b>Exceptions:</b></dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGit_1_1Exception.html" title="Exception class.">Exception</a></td><td>: in case the command failed </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8C_source.html#l00305">305</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment">{ POpenWrapper p(<span class="stringliteral">"git --git-dir="</span> + <a class="code" href="classGit.html#a5f478cb0fb21487e60f87b93d4277440" title="The path to the repository.">repository_</a> + <span class="stringliteral">" "</span> + gitCmd, <a class="code" href="classGit.html#a0097b8efc1e8530cc11133622684e9ef" title="A small LRU cache that stores results of git commands.">cache_</a>); std::string r; <span class="keywordflow">if</span> (p.exitStatus() != 0) <span class="keywordflow">throw</span> Exception(<span class="stringliteral">"Git error: "</span> + p.readLine(r)); <span class="keywordtype">int</span> result = 0; <span class="keywordflow">while</span> (!p.finished()) { p.readLine(r); ++result; } <span class="keywordflow">return</span> result; } </pre></div> </div> </div> <a class="anchor" id="ab432b071c7d22343a7ac136c35230251"></a><!-- doxytag: member="Git::getCommit" ref="ab432b071c7d22343a7ac136c35230251" args="(const std::string &revision) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classGit_1_1ObjectId.html">Git::ObjectId</a> Git::getCommit </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"><em>revision</em></td><td>)</td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>Get the commit for a particular revision. </p> <dl><dt><b>Exceptions:</b></dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGit_1_1Exception.html" title="Exception class.">Exception</a></td><td>: in case of a git error. </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8C_source.html#l00204">204</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment">{ std::string sha1Commit; <a class="code" href="classGit.html#a3dccd1727396de007ec5b43e96930a1b" title="Returns a line identified by a tag from the output of a git command.">getCmdResult</a>(<span class="stringliteral">"rev-parse "</span> + revision, sha1Commit, 0); <span class="keywordflow">return</span> ObjectId(sha1Commit); } </pre></div> </div> </div> <a class="anchor" id="a521bba51875ea14c9e39a14fcde01e04"></a><!-- doxytag: member="Git::getCommitTree" ref="a521bba51875ea14c9e39a14fcde01e04" args="(const std::string &revision) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classGit_1_1ObjectId.html">Git::ObjectId</a> Git::getCommitTree </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"><em>revision</em></td><td>)</td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>Get the tree for a particular revision. </p> <dl><dt><b>Exceptions:</b></dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGit_1_1Exception.html" title="Exception class.">Exception</a></td><td>: in case of a git error. </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8C_source.html#l00188">188</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment">{ <a class="code" href="classGit_1_1ObjectId.html" title="Git object Id.">Git::ObjectId</a> commit = <a class="code" href="classGit.html#ab432b071c7d22343a7ac136c35230251" title="Get the commit for a particular revision.">getCommit</a>(revision); <span class="keywordflow">return</span> <a class="code" href="classGit.html#a62bf9de2511aeb8e036a339ec8be8423" title="Get the tree for a particular commit.">getTreeFromCommit</a>(commit); } </pre></div> </div> </div> <a class="anchor" id="a62bf9de2511aeb8e036a339ec8be8423"></a><!-- doxytag: member="Git::getTreeFromCommit" ref="a62bf9de2511aeb8e036a339ec8be8423" args="(const ObjectId &commit) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classGit_1_1ObjectId.html">Git::ObjectId</a> Git::getTreeFromCommit </td> <td>(</td> <td class="paramtype">const <a class="el" href="classGit_1_1ObjectId.html">ObjectId</a> & </td> <td class="paramname"><em>commit</em></td><td>)</td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>Get the tree for a particular commit. </p> <dl><dt><b>Exceptions:</b></dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGit_1_1Exception.html" title="Exception class.">Exception</a></td><td>: in case of a git error. </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8C_source.html#l00211">211</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment">{ std::string treeLine; <span class="keywordflow">if</span> (!<a class="code" href="classGit.html#a3dccd1727396de007ec5b43e96930a1b" title="Returns a line identified by a tag from the output of a git command.">getCmdResult</a>(<span class="stringliteral">"cat-file -p "</span> + commit.toString(), treeLine, <span class="stringliteral">"tree"</span>)) <span class="keywordflow">throw</span> Exception(<span class="stringliteral">"Git: could not parse tree from commit '"</span> + commit.toString() + <span class="stringliteral">"'"</span>); std::vector<std::string> v; boost::split(v, treeLine, boost::is_any_of(<span class="stringliteral">" "</span>)); <span class="keywordflow">if</span> (v.size() != 2) <span class="keywordflow">throw</span> Exception(<span class="stringliteral">"Git: could not parse tree from commit '"</span> + commit.toString() + <span class="stringliteral">"': '"</span> + treeLine + <span class="stringliteral">"'"</span>); <span class="keywordflow">return</span> ObjectId(v[1]); } </pre></div> </div> </div> <a class="anchor" id="ab21f8d442557b07321a274b5e976f1ac"></a><!-- doxytag: member="Git::setRepositoryPath" ref="ab21f8d442557b07321a274b5e976f1ac" args="(const std::string &repository)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Git::setRepositoryPath </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"><em>repository</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Set the git repository path. </p> <dl><dt><b>Exceptions:</b></dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGit_1_1Exception.html" title="Exception class.">Exception</a></td><td>: if the path does not specify a valid repository. </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8C_source.html#l00182">182</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment">{ <a class="code" href="classGit.html#a5f478cb0fb21487e60f87b93d4277440" title="The path to the repository.">repository_</a> = repositoryPath; <a class="code" href="classGit.html#a04766dfcc9edcae7c12e6ff373176c7c" title="Checks the repository.">checkRepository</a>(); } </pre></div> </div> </div> <a class="anchor" id="a910f3a6123b494897cdedf7ba4ef648b"></a><!-- doxytag: member="Git::treeGetObject" ref="a910f3a6123b494897cdedf7ba4ef648b" args="(const ObjectId &tree, int index) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="structGit_1_1Object.html">Git::Object</a> Git::treeGetObject </td> <td>(</td> <td class="paramtype">const <a class="el" href="classGit_1_1ObjectId.html">ObjectId</a> & </td> <td class="paramname"><em>tree</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>index</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td> const</td> </tr> </table> </div> <div class="memdoc"> <p>Get some info on a tree object. </p> <p>The object is specified based on its index in the parent tree object.</p> <dl><dt><b>Exceptions:</b></dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGit_1_1Exception.html" title="Exception class.">Exception</a></td><td>: in case of a git error. </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8C_source.html#l00226">226</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment">{ std::string objectLine; <span class="keywordflow">if</span> (!<a class="code" href="classGit.html#a3dccd1727396de007ec5b43e96930a1b" title="Returns a line identified by a tag from the output of a git command.">getCmdResult</a>(<span class="stringliteral">"cat-file -p "</span> + tree.toString(), objectLine, index)) <span class="keywordflow">throw</span> Exception(<span class="stringliteral">"Git: could not read object %"</span> + boost::lexical_cast<std::string>(index) + <span class="stringliteral">" from tree "</span> + tree.toString()); <span class="keywordflow">else</span> { std::vector<std::string> v1, v2; boost::split(v1, objectLine, boost::is_any_of(<span class="stringliteral">"\t"</span>)); <span class="keywordflow">if</span> (v1.size() != 2) <span class="keywordflow">throw</span> Exception(<span class="stringliteral">"Git: could not parse tree object line: '"</span> + objectLine + <span class="stringliteral">"'"</span>); boost::split(v2, v1[0], boost::is_any_of(<span class="stringliteral">" "</span>)); <span class="keywordflow">if</span> (v2.size() != 3) <span class="keywordflow">throw</span> Exception(<span class="stringliteral">"Git: could not parse tree object line: '"</span> + objectLine + <span class="stringliteral">"'"</span>); <span class="keyword">const</span> std::string& stype = v2[1]; <a class="code" href="classGit.html#ab282f46c36a47ddff9bc7be7c993041a" title="Git object type.">ObjectType</a> type; <span class="keywordflow">if</span> (stype == <span class="stringliteral">"tree"</span>) type = <a class="code" href="classGit.html#ab282f46c36a47ddff9bc7be7c993041aae94d3a7ff6594f6b3b0dc121fbd01564">Tree</a>; <span class="keywordflow">else</span> <span class="keywordflow">if</span> (stype == <span class="stringliteral">"blob"</span>) type = <a class="code" href="classGit.html#ab282f46c36a47ddff9bc7be7c993041aa64c3a7b641cdc0cb2c4203fc0bef1a4a">Blob</a>; <span class="keywordflow">else</span> <span class="keywordflow">throw</span> Exception(<span class="stringliteral">"Git: Unknown type: "</span> + stype); <a class="code" href="structGit_1_1Object.html" title="Git object.">Git::Object</a> result(ObjectId(v2[2]), type); result.name = v1[1]; <span class="keywordflow">return</span> result; } } </pre></div> </div> </div> <a class="anchor" id="abe86381afbbab0adb0680ae268752f1f"></a><!-- doxytag: member="Git::treeSize" ref="abe86381afbbab0adb0680ae268752f1f" args="(const ObjectId &tree) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int Git::treeSize </td> <td>(</td> <td class="paramtype">const <a class="el" href="classGit_1_1ObjectId.html">ObjectId</a> & </td> <td class="paramname"><em>tree</em></td><td>)</td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>Return the number of objects inside a tree object. </p> <dl><dt><b>Exceptions:</b></dt><dd> <table class="exception"> <tr><td class="paramname"><a class="el" href="classGit_1_1Exception.html" title="Exception class.">Exception</a></td><td>: in case of a git error. </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="Git_8C_source.html#l00260">260</a> of file <a class="el" href="Git_8C_source.html">Git.C</a>.</p> <div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> <a class="code" href="classGit.html#a451e493481c2b397497107a6e60a6360" title="Returns the number of lines in the output of a git command.">getCmdResultLineCount</a>(<span class="stringliteral">"cat-file -p "</span> + tree.toString()); } </pre></div> </div> </div> <hr/><h2>Member Data Documentation</h2> <a class="anchor" id="a0097b8efc1e8530cc11133622684e9ef"></a><!-- doxytag: member="Git::cache_" ref="a0097b8efc1e8530cc11133622684e9ef" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classGit.html#a23da7b806839f7a482935a44142b04c9">Cache</a> <a class="el" href="classGit.html#a0097b8efc1e8530cc11133622684e9ef">Git::cache_</a><code> [mutable, private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>A small LRU cache that stores results of git commands. </p> <p>Definition at line <a class="el" href="Git_8h_source.html#l00128">128</a> of file <a class="el" href="Git_8h_source.html">Git.h</a>.</p> </div> </div> <a class="anchor" id="a5f478cb0fb21487e60f87b93d4277440"></a><!-- doxytag: member="Git::repository_" ref="a5f478cb0fb21487e60f87b93d4277440" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">std::string <a class="el" href="classGit.html#a5f478cb0fb21487e60f87b93d4277440">Git::repository_</a><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>The path to the repository. </p> <p>Definition at line <a class="el" href="Git_8h_source.html#l00124">124</a> of file <a class="el" href="Git_8h_source.html">Git.h</a>.</p> </div> </div> <hr/>The documentation for this class was generated from the following files:<ul> <li>/home/koen/project/wt/public-git/wt/examples/gitmodel/<a class="el" href="Git_8h_source.html">Git.h</a></li> <li>/home/koen/project/wt/public-git/wt/examples/gitmodel/<a class="el" href="Git_8C_source.html">Git.C</a></li> </ul> </div> <hr size="1"><address style="text-align: right; margin: 3px"><small> Generated on Thu Nov 1 2012 for <a href="http://www.webtoolkit.eu/wt">the C++ Web Toolkit (Wt)</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" border="0" style="vertical-align: middle; display: inline-block; height: 2em"></a> 1.7.5.1</small></address> </body> </html>