From 550cf16f98984a22cfb25354e9f37f86bcfe5c13 Mon Sep 17 00:00:00 2001
From: Documentation Generation
git_oid oid;
- git_oid_fromstr(&oid, hex);
If you have a oid, you can easily get the hex value of the SHA as well.
git_oid_fmt(out, &oid);
+ git_oid_fmt(out, &oid);
printf("SHA hex string: %s\n", out);
git_odb *odb;
- git_repository_odb(&odb, repo);
git_otype
enu
generated when the object was written to our database.
git_oid_fmt(out, &oid);
+ git_oid_fmt(out, &oid);
printf("Written Object: %s\n", out);
printf("\n*Commit Parsing*\n");
git_commit *commit;
- git_oid_fromstr(&oid, "8496071c1b46c854b31185ea97743be6a8774479");
+ git_oid_fromstr(&oid, "8496071c1b46c854b31185ea97743be6a8774479");
error = git_commit_lookup(&commit, repo, &oid);
check_error(error, "looking up commit");
@@ -511,7 +511,7 @@ technically have any number, though it's rare to have more than two.
for (p = 0;p < parents;p++) {
git_commit *parent;
git_commit_parent(&parent, commit, p);
- git_oid_fmt(out, git_commit_id(parent));
+ git_oid_fmt(out, git_commit_id(parent));
printf("Parent: %s\n", out);
git_commit_free(parent);
}
user.name
and
example file to see how to access config values.
git_signature_new((git_signature **)&author,
+ git_signature_new((git_signature **)&author,
"Scott Chacon", "schacon@gmail.com", 123456789, 60);
- git_signature_new((git_signature **)&cmtter,
+ git_signature_new((git_signature **)&cmtter,
"Scott A Chacon", "scott@github.com", 987654321, 90);
git_oid_fromstr(&tree_id, "f60079018b664e4e79329a7ef9559c8d9e0378d1");
- git_tree_lookup(&tree, repo, &tree_id);
- git_oid_fromstr(&parent_id, "5b5b025afb0b4c913b4c338a42934a3863bf3644");
+ git_oid_fromstr(&tree_id, "f60079018b664e4e79329a7ef9559c8d9e0378d1");
+ git_tree_lookup(&tree, repo, &tree_id);
+ git_oid_fromstr(&parent_id, "5b5b025afb0b4c913b4c338a42934a3863bf3644");
git_commit_lookup(&parent, repo, &parent_id);
Now we can take a look at the commit SHA we've generated.
git_oid_fmt(out, &commit_id);
+ git_oid_fmt(out, &commit_id);
printf("New Commit: %s\n", out);
git_oid_fromstr(&oid, "b25fa35b38051e4ae45d4222e795f9df2e43f1d1");
+ git_oid_fromstr(&oid, "b25fa35b38051e4ae45d4222e795f9df2e43f1d1");
- error = git_tag_lookup(&tag, repo, &oid);
+ error = git_tag_lookup(&tag, repo, &oid);
check_error(error, "looking up tag");
git_tag_target((git_object **)&commit, tag);
- tname = git_tag_name(tag); // "test"
- ttype = git_tag_target_type(tag); // GIT_OBJ_COMMIT (otype enum)
- tmessage = git_tag_message(tag); // "tag message\n"
+ git_tag_target((git_object **)&commit, tag);
+ tname = git_tag_name(tag); // "test"
+ ttype = git_tag_target_type(tag); // GIT_OBJ_COMMIT (otype enum)
+ tmessage = git_tag_message(tag); // "tag message\n"
printf("Tag Message: %s\n", tmessage);
git_commit_free(commit);
@@ -723,8 +723,8 @@ tree entries.
Create the oid and lookup the tree object just like the other objects.
git_oid_fromstr(&oid, "2a741c18ac5ff082a7caaec6e74db3075a1906b5");
- git_tree_lookup(&tree, repo, &oid);
git_oid_fromstr(&oid, "2a741c18ac5ff082a7caaec6e74db3075a1906b5");
+ git_tree_lookup(&tree, repo, &oid);
size_t cnt = git_tree_entrycount(tree); // 3
+ size_t cnt = git_tree_entrycount(tree); // 3
printf("tree entries: %d\n", (int)cnt);
- entry = git_tree_entry_byindex(tree, 0);
- printf("Entry name: %s\n", git_tree_entry_name(entry)); // "hello.c"
+ entry = git_tree_entry_byindex(tree, 0);
+ printf("Entry name: %s\n", git_tree_entry_name(entry)); // "hello.c"
entry = git_tree_entry_byname(tree, "README");
- git_tree_entry_name(entry); // "hello.c"
entry = git_tree_entry_byname(tree, "README");
+ git_tree_entry_name(entry); // "hello.c"
git_tree_entry_to_object(&objt, repo, entry); // blob
git_tree_entry_to_object(&objt, repo, entry); // blob
printf("\n*Blob Parsing*\n");
git_blob *blob;
- git_oid_fromstr(&oid, "1385f264afb75a56a5bec74243be9b367ba4ca08");
+ git_oid_fromstr(&oid, "1385f264afb75a56a5bec74243be9b367ba4ca08");
git_blob_lookup(&blob, repo, &oid);
git log
type functionality.
git_revwalk *walk;
git_commit *wcommit;
- git_oid_fromstr(&oid, "5b5b025afb0b4c913b4c338a42934a3863bf3644");
+ git_oid_fromstr(&oid, "5b5b025afb0b4c913b4c338a42934a3863bf3644");
branch2
and hide
of branch1
.
git_revwalk_new(&walk, repo);
- git_revwalk_sorting(walk, GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE);
- git_revwalk_push(walk, &oid);
+ git_revwalk_new(&walk, repo);
+ git_revwalk_sorting(walk, GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE);
+ git_revwalk_push(walk, &oid);
const git_signature *cauth;
const char *cmsg;
@@ -894,7 +894,7 @@ at by the returned OID; note that this operation is specially fast
since the raw contents of the commit object will be cached in memory
while ((git_revwalk_next(&oid, walk)) == 0) {
+ while ((git_revwalk_next(&oid, walk)) == 0) {
error = git_commit_lookup(&wcommit, repo, &oid);
check_error(error, "looking up commit during revwalk");
@@ -917,7 +917,7 @@ walked it not deallocated while the walk is in progress, or it will
result in undefined behavior
git_revwalk_free(walk);
git_revwalk_free(walk);
git_index_open_bare()
. The index for the repository
will be located and loaded from disk.
git_repository_index(&index, repo);
git_repository_index(&index, repo);
git_strarray ref_list;
- git_reference_list(&ref_list, repo);
+ git_reference_list(&ref_list, repo);
const char *refname;
git_reference *ref;
for (i = 0; i < ref_list.count; ++i) {
refname = ref_list.strings[i];
- git_reference_lookup(&ref, repo, refname);
+ git_reference_lookup(&ref, repo, refname);
- switch (git_reference_type(ref)) {
+ switch (git_reference_type(ref)) {
case GIT_REF_OID:
- git_oid_fmt(out, git_reference_target(ref));
+ git_oid_fmt(out, git_reference_target(ref));
printf("%s [%s]\n", refname, out);
break;
case GIT_REF_SYMBOLIC:
- printf("%s => %s\n", refname, git_reference_symbolic_target(ref));
+ printf("%s => %s\n", refname, git_reference_symbolic_target(ref));
break;
default:
fprintf(stderr, "Unexpected reference type\n");
@@ -1053,7 +1053,7 @@ one at a time and resolve them to the SHA, then print both values out.
}
}
- git_strarray_free(&ref_list);
git_repository_free(repo);
+ git_repository_free(repo);
return 0;
}
--
cgit v1.2.1