Permalink
Browse files

start of api guide

  • Loading branch information...
1 parent f728ed1 commit 5d93066a3cad3d24f90c669fdd3b1bfa65a7f930 @schacon schacon committed Dec 2, 2010
View
@@ -1 +1,2 @@
_site
+*.swp
View
133 api.html
@@ -0,0 +1,133 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <title>libgit2 API</title>
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
+ <link href="stylesheets/application.css" media="all" rel="stylesheet" type="text/css"/>
+ <link href="stylesheets/sunburst.css" media="all" rel="stylesheet" type="text/css"/>
+ <script type="text/javascript" src="js/sh_main.min.js"></script>
+ <script type="text/javascript" src="js/sh_lang/sh_c.min.js"></script>
+ <script type="text/javascript" src="js/sh_lang/sh_ruby.min.js"></script>
+ <link type="text/css" href="stylesheets/sh_libgit.css" rel="stylesheet" >
+ </head>
+
+ <body onload="sh_highlightDocument();">
+ <div id="body"><div id="contents">
+ <div id="header">
+ <h1>LibGit2 API Usage Guide</h1>
+ </div>
+
+ <h2 id="started">Getting started</h2>
+
+ <div class="contents"><div class="bullet">
+ <div class="description">
+ <p>This is the usage guide for the libgit2 API. The machine generated
+ documentation for the C API can be found <a href="http://libgit2.github.com/libgit2/modules.html">here</a>;
+ this page is to show some examples and usage of libgit2 and the Ruby
+ bindings, <a href="https://github.com/libgit2/rugged">Rugged</a>.
+ </p>
+
+ <p>To get started, you need to initialize the <code>Repository</code>
+ object. This is the starting point for most of what you will do with
+ the libgit2 API.
+ </p>
+
+<span class="shtitle">C</span>
+<pre class="sh_c">
+#include &lt;git.h&gt;
+git_repository *repo;
+git_repository_open(&repo, "/path/to/repo.git");
+git_repository_free(repo);
+</pre>
+
+<br/>
+
+<span class="shtitle">Ruby</span>
+<pre class="sh_ruby">
+require 'rugged'
+repo = Rugged::Repository.new(@path)
+</pre>
+
+ </div>
+ </div></div>
+
+
+
+ <h2 id="sha">SHA1 Conversion and Formatting</h2>
+ <div class="contents"><div class="bullet">
+ <div class="description">
+
+ <h3>Hex to Raw</h3>
+
+<span class="shtitle">C</span>
+<pre class="sh_c">
+char hex[] = "599955586da1c3ad514f3e65f1081d2012ec862d";
+git_oid oid;
+git_oid_mkstr(&oid, hex);
+printf("Raw 20 bytes: [%s]\n", (&oid)->id);
+</pre>
+
+<br/>
+
+<span class="shtitle">Ruby</span>
+<pre class="sh_ruby">
+raw = Rugged::hex_to_raw("ce08fe4884650f067bd5703b6a59a8b3b3c99a09")
+puts "Raw 20 bytes: #{raw}"
+</pre>
+
+ <h3>Raw to Hex</h3>
+
+<span class="shtitle">C</span>
+<pre class="sh_c">
+git_oid oid;
+char out[40];
+
+git_oid_mkraw(&oid, raw);
+git_oid_fmt(out, &oid);
+printf("SHA hex string: %s\n", out);$
+</pre>
+
+<br/>
+
+<span class="shtitle">Ruby</span>
+<pre class="sh_ruby">
+hex = Rugged::raw_to_hex(Base64.decode64("FqASNFZ4mrze9Ld1ITwjqL109eA="))
+puts "SHA hex string: #{hex}"
+</pre>
+
+ </div>
+ </div></div>
+
+ <h2 id="sha">Raw Data Reading and Writing</h2>
+ <div class="contents"><div class="bullet">
+ <div class="description">
+ loose and packed
+ </div>
+ </div></div>
+
+ <h2 id="sha">Object Parsing and Writing</h2>
+ <div class="contents"><div class="bullet">
+ <div class="description">
+ commit, tag, tree and blob parsing and write-back
+ tree traversal
+ </div>
+ </div></div>
+
+ <h2 id="sha">Revision Walking</h2>
+ <div class="contents"><div class="bullet">
+ <div class="description">
+ </div>
+ </div></div>
+
+ <h2 id="sha">Index Manipulation</h2>
+ <div class="contents"><div class="bullet">
+ <div class="description">
+ </div>
+ </div></div>
+
+ <a href="http://github.com/libgit2/libgit2" id="github">
+ <img alt="Fork me on GitHub" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" />
+ </a>
+</body>
+</html>
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -379,3 +379,10 @@ pre {
#versions a.current {
font-weight: bold;
}
+
+.shtitle {
+ background: #595;
+ color: #cec;
+ padding: 8px;
+ float: right;
+}
View
@@ -0,0 +1,154 @@
+pre.sh_sourceCode {
+ background-color: #000000;
+ color: #ffffff;
+ font-weight: normal;
+ font-style: normal;
+ font-family: Monaco, monospace;
+ font-size: 13px;
+ padding: 10px;
+}
+
+pre.sh_sourceCode .sh_keyword {
+ color: #E28964;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_type {
+ color: #89BDFF;
+ font-weight: normal;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_string {
+ color: #65B042;
+ font-weight: bold;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_regexp {
+ color: #CF7D34;
+ font-weight: bold;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_specialchar {
+ color: #CF7D34;
+ font-weight: normal;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_comment {
+ color: #AEAEAE;
+ font-weight: normal;
+ font-style: italic;
+}
+
+pre.sh_sourceCode .sh_number {
+ color: #89BDFF;
+ font-weight: normal;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_preproc {
+ color: #AFC4DB;
+ font-weight: normal;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_symbol {
+ color: #3387CC;
+ font-weight: normal;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_function {
+ color: #99CF50;
+ color: #E0C589;
+ font-weight: normal;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_cbracket {
+ color: #E0C589;
+ font-weight: normal;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_url {
+ color: #E28964;
+ font-weight: bold;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_date {
+ color: #8F9D6A;
+ font-weight: bold;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_time {
+ color: #8B98AB;
+ font-weight: bold;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_file {
+ color: #ffff66;
+ font-weight: bold;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_ip {
+ color: #abab66;
+ font-weight: bold;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_name {
+ color: #E18964;
+ font-weight: bold;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_variable {
+ color: #26e0e7;
+ font-weight: normal;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_oldfile {
+ color: #bfbfbf;
+ font-weight: normal;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_newfile {
+ color: #abab66;
+ font-weight: bold;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_difflines {
+ color: #ffff66;
+ font-weight: bold;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_selector {
+ color: #26e0e7;
+ font-weight: normal;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_property {
+ color: #ffff66;
+ font-weight: bold;
+ font-style: normal;
+}
+
+pre.sh_sourceCode .sh_value {
+ color: #abab66;
+ font-weight: bold;
+ font-style: normal;
+}
+

0 comments on commit 5d93066

Please sign in to comment.