@@ -749,6 +749,58 @@ int error = git_tag_peel(&dereferenced_target, tag);
749
749
)
750
750
751
751
752
+ <h2 id =" blobs " >Blobs</h2 >
753
+
754
+ <h3 id =" blobs_lookups " >Lookups</h3 >
755
+
756
+ ``` c
757
+ git_blob *blob = NULL ;
758
+ int error = git_blob_lookup(&blob, repo, &oid);
759
+ ```
760
+
761
+ (
762
+ [ ` git_blob_lookup ` ] ( http://libgit2.github.com/libgit2/#HEAD/group/blob/git_blob_lookup )
763
+ )
764
+
765
+ <h3 id =" blobs_content " >Content</h3 >
766
+
767
+ ``` c
768
+ git_off_t rawsize = git_blob_rawsize(blob);
769
+ const void *rawcontent = git_blob_rawcontent(blob);
770
+
771
+ git_buf filtered_content = GIT_BUF_INIT;
772
+ int error = git_blob_filtered_content(
773
+ &filtered_content, /* output buffer */
774
+ blob, /* blob */
775
+ " README.md" , /* path (for attribute-based filtering) */
776
+ true ); /* check if binary? */
777
+ git_buf_free (&filtered_content);
778
+ ```
779
+
780
+ (
781
+ [`git_blob_rawsize`](http://libgit2.github.com/libgit2/#HEAD/group/blob/git_blob_rawsize),
782
+ [`git_blob_rawcontent`](http://libgit2.github.com/libgit2/#HEAD/group/blob/git_blob_rawcontent),
783
+ [`git_blob_filtered_content`](http://libgit2.github.com/libgit2/#HEAD/group/blob/git_blob_filtered_content)
784
+ )
785
+
786
+ <h3 id="blobs_create">Create</h3>
787
+
788
+ ```c
789
+ git_oid oid = {{0}};
790
+ int error = git_blob_create_fromworkdir(&oid, repo, "README.md");
791
+ error = git_blob_create_fromdisk(&oid, repo, "/etc/hosts");
792
+
793
+ const char str[] = "# Hello there!";
794
+ error = git_blob_create_frombuffer(&oid, repo, str, strlen(str));
795
+ ```
796
+
797
+ (
798
+ [ ` git_blob_create_fromworkdir ` ] ( http://libgit2.github.com/libgit2/#HEAD/group/blob/git_blob_create_fromworkdir ) ,
799
+ [ ` git_blob_create_fromdisk ` ] ( http://libgit2.github.com/libgit2/#HEAD/group/blob/git_blob_create_fromdisk ) ,
800
+ [ ` git_blob_create_frombuffer ` ] ( http://libgit2.github.com/libgit2/#HEAD/group/blob/git_blob_create_frombuffer )
801
+ )
802
+
803
+
752
804
<h2 id="trees">Trees</h2>
753
805
754
806
<h3 id="trees_lookups">Lookups</h3>
@@ -870,6 +922,98 @@ git_treebuilder_free(bld);
870
922
[`git_treebuilder_free`](http://libgit2.github.com/libgit2/#HEAD/group/treebuilder/git_treebuilder_free))
871
923
872
924
925
+ <h2 id="commits">Commits</h2>
926
+
927
+ <h3 id="commits_lookups">Lookups</h3>
928
+
929
+ ```c
930
+ git_commit *commit;
931
+ int error = git_commit_lookup(&commit, repo, &oid);
932
+ ```
933
+
934
+ (
935
+ [ ` git_commit_lookup ` ] ( http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_lookup )
936
+ )
937
+
938
+ <h3 id="commits_properties">Properties</h3>
939
+
940
+ ```c
941
+ const git_oid *oid = git_commit_id(commit);
942
+ const char * encoding = git_commit_message_encoding(commit);
943
+ const char * message = git_commit_message(commit);
944
+ const char * summmary = git_commit_summary(commit);
945
+ git_time_t time = git_commit_time(commit);
946
+ int offset_in_min = git_commit_time_offset(commit);
947
+ const git_signature * committer = git_commit_committer(commit);
948
+ const git_signature * author = git_commit_author(commit);
949
+ const char * header = git_commit_raw_header(commit);
950
+ const git_oid * tree_id = git_commit_tree_id(commit);
951
+ ```
952
+
953
+ (
954
+ [`git_commit_id`](http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_id),
955
+ [`git_commit_message_encoding`](http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_message_encoding),
956
+ [`git_commit_message`](http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_message),
957
+ [`git_commit_summary`](http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_summary),
958
+ [`git_commit_time`](http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_time),
959
+ [`git_commit_time_offset`](http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_time_offset),
960
+ [`git_commit_committer`](http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_committer),
961
+ [`git_commit_author`](http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_author),
962
+ [`git_commit_raw_header`](http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_raw_header),
963
+ [`git_commit_tree_id`](http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_tree_id)
964
+ )
965
+
966
+ <h3 id="commits_parents">Parents</h3>
967
+
968
+ ```c
969
+ unsigned int count = git_commit_parentcount(commit);
970
+ for (unsigned int i=0; i<count; i++) {
971
+ git_oid *nth_parent_id = git_commit_parent_id(commit);
972
+
973
+ git_commit *nth_parent = NULL;
974
+ int error = git_commit_parent(&nth_parent, commit, i);
975
+ /* … */
976
+ }
977
+
978
+ git_commit *nth_ancestor = NULL;
979
+ int error = git_commit_nth_gen_ancestor(&nth_ancestor, commit, 7);
980
+ ```
981
+
982
+ (
983
+ [ ` git_commit_parentcount ` ] ( http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_parentcount ) ,
984
+ [ ` git_commit_parent_id ` ] ( http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_parent_id ) ,
985
+ [ ` git_commit_parent ` ] ( http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_parent ) ,
986
+ [ ` git_commit_nth_gen_ancestor ` ] ( http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_nth_gen_ancestor )
987
+ )
988
+
989
+ <h3 id="commits_create">Create</h3>
990
+
991
+ ```c
992
+ git_signature *me = NULL
993
+ int error = git_signature_now(&me, "Me", "
[email protected] ");
994
+
995
+ const git_commit * parents[ ] = {parent1, parent2};
996
+
997
+ git_oid new_commit_id = {{0}};
998
+ error = git_commit_create(
999
+ &new_commit_id,
1000
+ repo,
1001
+ "HEAD", /* name of ref to update * /
1002
+ me, /* author * /
1003
+ me, /* committer * /
1004
+ "UTF-8", /* message encoding * /
1005
+ "Flooberhaul the whatnots", /* message * /
1006
+ tree, /* root tree * /
1007
+ 2, /* parent count * /
1008
+ parents); /* parents * /
1009
+ ```
1010
+
1011
+ (
1012
+ [`git_signature_now`](http://libgit2.github.com/libgit2/#HEAD/group/signature/git_signature_now),
1013
+ [`git_commit_create`](http://libgit2.github.com/libgit2/#HEAD/group/commit/git_commit_create)
1014
+ )
1015
+
1016
+
873
1017
<h2 id="revwalk">Revwalk</h2>
874
1018
875
1019
<h3 id="revwalk_simple">Simple</h3>
0 commit comments