Skip to content

Commit 3cf1fbb

Browse files
committed
Fix some documentation in 101 Libgit2 Samples
Remove misleading information from the treebuilder section. Add a short text describing the tree and treebuilder objects.
1 parent f9ae763 commit 3cf1fbb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docs/guides/101-samples/index.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ error = git_blob_create_frombuffer(&oid, repo, str, strlen(str));
304304

305305
<h2 id="trees">Trees</h2>
306306

307+
A tree object in libgit2 is more like a directory. It can represent a directory
308+
tree by containing references to other trees.
309+
307310
<h3 id="trees_lookups">Lookups</h3>
308311

309312
Each commit has a tree:
@@ -391,6 +394,10 @@ error = git_tree_walk(tree, GIT_TREEWALK_PRE, walk_cb, &d);
391394

392395
<h3 id="trees_treebuilder">Treebuilder</h3>
393396

397+
Since trees in git are immutable we need a mechanism to build them. This method
398+
in libgit2 is the treebuilder. Just like the tree object, the treebuilder object
399+
represents a single directory containing other objects.
400+
394401
```c
395402
git_treebuilder *bld = NULL;
396403
int error = git_treebuilder_create(&bld, NULL);
@@ -405,7 +412,7 @@ error = git_treebuilder_insert(NULL, bld,
405412
git_object_free(obj);
406413
error = git_revparse_single(&obj, repo, "v0.1.0:foo/bar/baz.c");
407414
error = git_treebuilder_insert(NULL, bld,
408-
"a/b/d.c",
415+
"d.c",
409416
git_object_id(obj),
410417
0100644);
411418
git_object_free(obj);

0 commit comments

Comments
 (0)