Skip to content

Commit 15bff63

Browse files
committed
Simple first
1 parent 334a485 commit 15bff63

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/guides/101-samples/index.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,11 @@ if (git_index_has_conflicts(idx)) {
929929
<h3 id="index_add">Add & Remove</h3>
930930

931931
```c
932+
/* Force a single file to be added (even if it is ignored) */
933+
error = git_index_add_bypath(idx, "path/to/file.py");
934+
/* … or removed */
935+
error = git_index_remove_bypath(idx, "path/to/file.py");
936+
932937
typedef struct { /**/ } match_data;
933938
int match_cb(const char *path, const char *spec, void *payload)
934939
{
@@ -943,7 +948,7 @@ int match_cb(const char *path, const char *spec, void *payload)
943948
const char *paths[] = {"src/*", "test/*"};
944949
git_strarray arr = {paths, 2};
945950

946-
/* Add matching files; this skips ignored files */
951+
/* Add matching files (this skips ignored files) */
947952
match_data d = {0};
948953
int error = git_index_add_all(idx, &arr, GIT_INDEX_ADD_DEFAULT,
949954
match_cb, &d);
@@ -952,20 +957,15 @@ error = git_index_remove_all(idx, &arr, match_cb, &d);
952957

953958
/* Something like 'git add .' */
954959
error = git_index_update_all(idx, &arr, match_cb, &d);
955-
956-
/* Force a single file to be added (even if it is ignored) */
957-
error = git_index_add_bypath(idx, "path/to/file.py");
958-
/* …or removed */
959-
error = git_index_remove_bypath(idx, "path/to/file.py");
960960
```
961961
962962
(
963+
[`git_index_add_bypath`](http://libgit2.github.com/libgit2/#HEAD/group/index/git_index_add_bypath),
964+
[`git_index_remove_bypath`](http://libgit2.github.com/libgit2/#HEAD/group/index/git_index_remove_bypath),
963965
[`git_strarray`](http://libgit2.github.com/libgit2/#HEAD/type/git_strarray),
964966
[`git_index_add_all`](http://libgit2.github.com/libgit2/#HEAD/group/index/git_index_add_all),
965967
[`git_index_remove_all`](http://libgit2.github.com/libgit2/#HEAD/group/index/git_index_remove_all),
966-
[`git_index_update_all`](http://libgit2.github.com/libgit2/#HEAD/group/index/git_index_update_all),
967-
[`git_index_add_bypath`](http://libgit2.github.com/libgit2/#HEAD/group/index/git_index_add_bypath),
968-
[`git_index_remove_bypath`](http://libgit2.github.com/libgit2/#HEAD/group/index/git_index_remove_bypath)
968+
[`git_index_update_all`](http://libgit2.github.com/libgit2/#HEAD/group/index/git_index_update_all)
969969
)
970970
971971

0 commit comments

Comments
 (0)