Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
96da90ae
Commit
96da90ae
authored
Jun 15, 2011
by
Scott Chacon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update examples content to be compilable and up to date
parent
2e6d8ec4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
5 deletions
+40
-5
api.docurium
+1
-1
examples/.gitignore
+2
-0
examples/Makefile
+10
-0
examples/general.c
+25
-2
examples/showindex.c
+2
-2
No files found.
api.docurium
View file @
96da90ae
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
"input": "include/git2",
"input": "include/git2",
"prefix": "git_",
"prefix": "git_",
"output": "docs",
"output": "docs",
"
x
branch": "gh-pages",
"branch": "gh-pages",
"examples": "examples",
"examples": "examples",
"legacy": {
"legacy": {
"input": {"src/git": ["v0.1.0"],
"input": {"src/git": ["v0.1.0"],
...
...
examples/.gitignore
0 → 100644
View file @
96da90ae
general
showindex
examples/Makefile
0 → 100644
View file @
96da90ae
all
:
general showindex
general
:
general.c
gcc
-lgit2
-o
general general.c
showindex
:
showindex.c
gcc
-lgit2
-o
showindex showindex.c
clean
:
rm general showindex
examples/
libgit
.c
→
examples/
general
.c
View file @
96da90ae
...
@@ -246,7 +246,7 @@ int main (int argc, char** argv)
...
@@ -246,7 +246,7 @@ int main (int argc, char** argv)
printf
(
"
\n
*Tree Parsing*
\n
"
);
printf
(
"
\n
*Tree Parsing*
\n
"
);
git_tree
*
tree
;
git_tree
*
tree
;
git_tree_entry
*
entry
;
const
git_tree_entry
*
entry
;
git_object
*
objt
;
git_object
*
objt
;
// Create the oid and lookup the tree object just like the other objects.
// Create the oid and lookup the tree object just like the other objects.
...
@@ -356,7 +356,7 @@ int main (int argc, char** argv)
...
@@ -356,7 +356,7 @@ int main (int argc, char** argv)
// You can either open the index from the standard location in an open repository, as we're doing
// You can either open the index from the standard location in an open repository, as we're doing
// here, or you can open and manipulate any index file with `git_index_open_bare()`. The index
// here, or you can open and manipulate any index file with `git_index_open_bare()`. The index
// for the repository will be located and loaded from disk.
// for the repository will be located and loaded from disk.
git_
index_open_inrepo
(
&
index
,
repo
);
git_
repository_index
(
&
index
,
repo
);
// For each entry in the index, you can get a bunch of information including the SHA (oid), path
// For each entry in the index, you can get a bunch of information including the SHA (oid), path
// and mode which map to the tree objects that are written out. It also has filesystem properties
// and mode which map to the tree objects that are written out. It also has filesystem properties
...
@@ -410,6 +410,29 @@ int main (int argc, char** argv)
...
@@ -410,6 +410,29 @@ int main (int argc, char** argv)
git_strarray_free
(
&
ref_list
);
git_strarray_free
(
&
ref_list
);
// ### Config Files
//
// The [config API][config] allows you to list and updatee config values in
// any of the accessible config file locations (system, global, local).
//
// [config]: http://libgit2.github.com/libgit2/#HEAD/group/config
printf
(
"
\n
*Config Listing*
\n
"
);
const
char
*
email
;
int
j
;
git_config
*
cfg
;
// Open a config object so we can read global values from it.
git_config_open_global
(
&
cfg
);
git_config_get_int
(
cfg
,
"help.autocorrect"
,
&
j
);
printf
(
"Autocorrect: %d
\n
"
,
j
);
git_config_get_string
(
cfg
,
"user.email"
,
&
email
);
printf
(
"Email: %s
\n
"
,
email
);
// Finally, when you're done with the repository, you can free it as well.
// Finally, when you're done with the repository, you can free it as well.
git_repository_free
(
repo
);
git_repository_free
(
repo
);
}
}
...
...
examples/showindex.c
View file @
96da90ae
...
@@ -12,9 +12,9 @@ int main (int argc, char** argv)
...
@@ -12,9 +12,9 @@ int main (int argc, char** argv)
char
out
[
41
];
char
out
[
41
];
out
[
40
]
=
'\0'
;
out
[
40
]
=
'\0'
;
git_repository_open
(
&
repo
,
"/
tmp/gittalk
/.git"
);
git_repository_open
(
&
repo
,
"/
opt/libgit2-test
/.git"
);
git_
index_open_inrepo
(
&
index
,
repo
);
git_
repository_index
(
&
index
,
repo
);
git_index_read
(
index
);
git_index_read
(
index
);
ecount
=
git_index_entrycount
(
index
);
ecount
=
git_index_entrycount
(
index
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment