diff options
Diffstat (limited to 'ex/HEAD/config.html')
-rw-r--r-- | ex/HEAD/config.html | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/ex/HEAD/config.html b/ex/HEAD/config.html index 2a20b5e85..318334d46 100644 --- a/ex/HEAD/config.html +++ b/ex/HEAD/config.html @@ -57,94 +57,6 @@ </tr> </thead> <tbody> - <tr id='section-1'> - <td class=docs> - <div class="pilwrap"> - <a class="pilcrow" href="#section-1">¶</a> - </div> - - </td> - <td class=code> - <div class='highlight'><pre><span></span><span class="cm">/*</span> -<span class="cm"> * libgit2 "config" example - shows how to use the config API</span> -<span class="cm"> *</span> -<span class="cm"> * Written by the libgit2 contributors</span> -<span class="cm"> *</span> -<span class="cm"> * To the extent possible under law, the author(s) have dedicated all copyright</span> -<span class="cm"> * and related and neighboring rights to this software to the public domain</span> -<span class="cm"> * worldwide. This software is distributed without any warranty.</span> -<span class="cm"> *</span> -<span class="cm"> * You should have received a copy of the CC0 Public Domain Dedication along</span> -<span class="cm"> * with this software. If not, see</span> -<span class="cm"> * <http://creativecommons.org/publicdomain/zero/1.0/>.</span> -<span class="cm"> */</span> - -<span class="cp">#include</span> <span class="cpf">"common.h"</span><span class="cp"></span> - -<span class="k">static</span> <span class="kt">int</span> <span class="nf">config_get</span><span class="p">(</span><span class="n">git_config</span> <span class="o">*</span><span class="n">cfg</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">key</span><span class="p">)</span> -<span class="p">{</span> - <span class="n">git_config_entry</span> <span class="o">*</span><span class="n">entry</span><span class="p">;</span> - <span class="kt">int</span> <span class="n">error</span><span class="p">;</span> - - <span class="k">if</span> <span class="p">((</span><span class="n">error</span> <span class="o">=</span> <span class="n"><a name="git_config_get_entry-4" class="fnlink" href="../../#HEAD/group/config/git_config_get_entry">git_config_get_entry</a></span><span class="p">(</span><span class="o">&</span><span class="n">entry</span><span class="p">,</span> <span class="n">cfg</span><span class="p">,</span> <span class="n">key</span><span class="p">))</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> - <span class="k">if</span> <span class="p">(</span><span class="n">error</span> <span class="o">!=</span> <span class="n">GIT_ENOTFOUND</span><span class="p">)</span> - <span class="n">printf</span><span class="p">(</span><span class="s">"Unable to get configuration: %s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n"><a name="git_error_last-6" class="fnlink" href="../../#HEAD/group/error/git_error_last">git_error_last</a></span><span class="p">()</span><span class="o">-></span><span class="n">message</span><span class="p">);</span> - <span class="k">return</span> <span class="mi">1</span><span class="p">;</span> - <span class="p">}</span> - - <span class="n">puts</span><span class="p">(</span><span class="n">entry</span><span class="o">-></span><span class="n">value</span><span class="p">);</span> - - <span class="cm">/* Free the git_config_entry after use with `<a name="git_config_entry_free-1" class="fnlink" href="../../#HEAD/group/config/git_config_entry_free">git_config_entry_free</a>()`. */</span> - <span class="n"><a name="git_config_entry_free-2" class="fnlink" href="../../#HEAD/group/config/git_config_entry_free">git_config_entry_free</a></span><span class="p">(</span><span class="n">entry</span><span class="p">);</span> - - <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> -<span class="p">}</span> - -<span class="k">static</span> <span class="kt">int</span> <span class="nf">config_set</span><span class="p">(</span><span class="n">git_config</span> <span class="o">*</span><span class="n">cfg</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">key</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">value</span><span class="p">)</span> -<span class="p">{</span> - <span class="k">if</span> <span class="p">(</span><span class="n"><a name="git_config_set_string-5" class="fnlink" href="../../#HEAD/group/config/git_config_set_string">git_config_set_string</a></span><span class="p">(</span><span class="n">cfg</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> - <span class="n">printf</span><span class="p">(</span><span class="s">"Unable to set configuration: %s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n"><a name="git_error_last-7" class="fnlink" href="../../#HEAD/group/error/git_error_last">git_error_last</a></span><span class="p">()</span><span class="o">-></span><span class="n">message</span><span class="p">);</span> - <span class="k">return</span> <span class="mi">1</span><span class="p">;</span> - <span class="p">}</span> - <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> -<span class="p">}</span> - -<span class="kt">int</span> <span class="nf">lg2_config</span><span class="p">(</span><span class="n">git_repository</span> <span class="o">*</span><span class="n">repo</span><span class="p">,</span> <span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span> -<span class="p">{</span> - <span class="n">git_config</span> <span class="o">*</span><span class="n">cfg</span><span class="p">;</span> - <span class="kt">int</span> <span class="n">error</span><span class="p">;</span> - - <span class="k">if</span> <span class="p">((</span><span class="n">error</span> <span class="o">=</span> <span class="n"><a name="git_repository_config-9" class="fnlink" href="../../#HEAD/group/repository/git_repository_config">git_repository_config</a></span><span class="p">(</span><span class="o">&</span><span class="n">cfg</span><span class="p">,</span> <span class="n">repo</span><span class="p">))</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> - <span class="n">printf</span><span class="p">(</span><span class="s">"Unable to obtain repository config: %s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n"><a name="git_error_last-8" class="fnlink" href="../../#HEAD/group/error/git_error_last">git_error_last</a></span><span class="p">()</span><span class="o">-></span><span class="n">message</span><span class="p">);</span> - <span class="k">goto</span> <span class="n">out</span><span class="p">;</span> - <span class="p">}</span> - - <span class="k">if</span> <span class="p">(</span><span class="n">argc</span> <span class="o">==</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span> - <span class="n">error</span> <span class="o">=</span> <span class="n">config_get</span><span class="p">(</span><span class="n">cfg</span><span class="p">,</span> <span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">]);</span> - <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">argc</span> <span class="o">==</span> <span class="mi">3</span><span class="p">)</span> <span class="p">{</span> - <span class="n">error</span> <span class="o">=</span> <span class="n">config_set</span><span class="p">(</span><span class="n">cfg</span><span class="p">,</span> <span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">argv</span><span class="p">[</span><span class="mi">2</span><span class="p">]);</span> - <span class="p">}</span> <span class="k">else</span> <span class="p">{</span> - <span class="n">printf</span><span class="p">(</span><span class="s">"USAGE: %s config <KEY> [<VALUE>]</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span> - <span class="n">error</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> - <span class="p">}</span></pre></div> - </td> - </tr> - <tr id='section-2'> - <td class=docs> - <div class="pilwrap"> - <a class="pilcrow" href="#section-2">¶</a> - </div> - <p>The configuration file must be freed once it's no longer -being used by the user.</p> - - </td> - <td class=code> - <div class='highlight'><pre> <span class="n"><a name="git_config_free-3" class="fnlink" href="../../#HEAD/group/config/git_config_free">git_config_free</a></span><span class="p">(</span><span class="n">cfg</span><span class="p">);</span> -<span class="nl">out</span><span class="p">:</span> - <span class="k">return</span> <span class="n">error</span><span class="p">;</span> -<span class="p">}</span></pre></div> - </td> - </tr> </table> </div> </body> |