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
58deac77
Commit
58deac77
authored
Oct 07, 2017
by
Edward Thomson
Committed by
GitHub
Oct 07, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4370 from libgit2/example_general
Fix Issue #4047 Check return codes and free objects
parents
e523826c
f4770e47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
examples/general.c
+28
-3
No files found.
examples/general.c
View file @
58deac77
...
...
@@ -724,6 +724,7 @@ static void config_files(const char *repo_path, git_repository* repo)
int32_t
autocorrect
;
git_config
*
cfg
;
git_config
*
snap_cfg
;
int
error_code
;
printf
(
"
\n
*Config Listing*
\n
"
);
...
...
@@ -740,9 +741,33 @@ static void config_files(const char *repo_path, git_repository* repo)
git_config_get_string
(
&
email
,
snap_cfg
,
"user.email"
);
printf
(
"Email: %s
\n
"
,
email
);
/**
* Remember to free the configurations after usage.
*/
error_code
=
git_config_get_int32
(
&
autocorrect
,
cfg
,
"help.autocorrect"
);
switch
(
error_code
)
{
case
0
:
printf
(
"Autocorrect: %d
\n
"
,
autocorrect
);
break
;
case
GIT_ENOTFOUND
:
printf
(
"Autocorrect: Undefined
\n
"
);
break
;
default:
check_error
(
error_code
,
"get_int32 failed"
);
}
git_config_free
(
cfg
);
check_error
(
git_repository_config_snapshot
(
&
snap_cfg
,
repo
),
"config snapshot"
);
error_code
=
git_config_get_string
(
&
email
,
snap_cfg
,
"user.email"
);
switch
(
error_code
)
{
case
0
:
printf
(
"Email: %s
\n
"
,
email
);
break
;
case
GIT_ENOTFOUND
:
printf
(
"Email: Undefined
\n
"
);
break
;
default:
check_error
(
error_code
,
"get_string failed"
);
}
git_config_free
(
snap_cfg
);
}
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