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
32234541
Commit
32234541
authored
May 17, 2011
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement git_config_open_global
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent
c9662061
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
include/git2/config.h
+7
-0
src/config.c
+34
-0
No files found.
include/git2/config.h
View file @
32234541
...
@@ -51,6 +51,13 @@ GIT_EXTERN(int) git_config_new(git_config **out);
...
@@ -51,6 +51,13 @@ GIT_EXTERN(int) git_config_new(git_config **out);
GIT_EXTERN
(
int
)
git_config_open_bare
(
git_config
**
cfg_out
,
const
char
*
path
);
GIT_EXTERN
(
int
)
git_config_open_bare
(
git_config
**
cfg_out
,
const
char
*
path
);
/**
/**
* Open the global configuration file at $HOME/.gitconfig
*
* @param cfg pointer to the configuration
*/
GIT_EXTERN
(
int
)
git_config_open_global
(
git_config
**
cfg
);
/**
*
*
*/
*/
GIT_EXTERN
(
int
)
git_config_add_backend
(
git_config
*
cfg
,
git_config_backend
*
backend
,
int
priority
);
GIT_EXTERN
(
int
)
git_config_add_backend
(
git_config
*
cfg
,
git_config_backend
*
backend
,
int
priority
);
...
...
src/config.c
View file @
32234541
...
@@ -70,6 +70,40 @@ int git_config_open_bare(git_config **out, const char *path)
...
@@ -70,6 +70,40 @@ int git_config_open_bare(git_config **out, const char *path)
return
error
;
return
error
;
}
}
int
git_config_open_global
(
git_config
**
out
)
{
char
*
home
=
NULL
,
*
filename
=
NULL
;
const
char
*
gitconfig
=
".gitconfig"
;
int
filename_len
,
ret
,
error
;
home
=
git__strdup
(
getenv
(
"HOME"
));
if
(
home
==
NULL
)
return
GIT_ENOMEM
;
filename_len
=
strlen
(
home
)
+
strlen
(
gitconfig
)
+
1
;
filename
=
git__malloc
(
filename_len
+
1
);
if
(
filename
==
NULL
)
{
error
=
GIT_ENOMEM
;
goto
out
;
}
ret
=
snprintf
(
filename
,
filename_len
,
"%s/%s"
,
home
,
gitconfig
);
if
(
ret
<
0
)
{
error
=
git__throw
(
GIT_EOSERR
,
"Failed to build global filename. OS err: %s"
,
strerror
(
errno
));
goto
out
;
}
else
if
(
ret
>=
filename_len
)
{
error
=
git__throw
(
GIT_ERROR
,
"Failed to build global filename. Length calulation wrong"
);
goto
out
;
}
error
=
git_config_open_bare
(
out
,
filename
);
out:
free
(
home
);
free
(
filename
);
return
error
;
}
void
git_config_free
(
git_config
*
cfg
)
void
git_config_free
(
git_config
*
cfg
)
{
{
unsigned
int
i
;
unsigned
int
i
;
...
...
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