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
c18a2bc4
Commit
c18a2bc4
authored
Jul 05, 2016
by
Edward Thomson
Committed by
GitHub
Jul 05, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3851 from txdv/get-user-agent
Add get user agent functionality.
parents
b57c176a
f1dba144
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
0 deletions
+19
-0
CHANGELOG.md
+4
-0
include/git2/common.h
+1
-0
src/settings.c
+8
-0
tests/core/useragent.c
+6
-0
No files found.
CHANGELOG.md
View file @
c18a2bc4
...
@@ -12,6 +12,10 @@ v0.24 + 1
...
@@ -12,6 +12,10 @@ v0.24 + 1
### API additions
### API additions
*
You can now get the user-agent used by libgit2 using the
`GIT_OPT_GET_USER_AGENT`
option with
`git_libgit2_opts()`
.
It is the counterpart to
`GIT_OPT_SET_USER_AGENT`
.
*
`git_commit_create_buffer()`
creates a commit and writes it into a
*
`git_commit_create_buffer()`
creates a commit and writes it into a
user-provided buffer instead of writing it into the object db.
user-provided buffer instead of writing it into the object db.
...
...
include/git2/common.h
View file @
c18a2bc4
...
@@ -158,6 +158,7 @@ typedef enum {
...
@@ -158,6 +158,7 @@ typedef enum {
GIT_OPT_SET_USER_AGENT
,
GIT_OPT_SET_USER_AGENT
,
GIT_OPT_ENABLE_STRICT_OBJECT_CREATION
,
GIT_OPT_ENABLE_STRICT_OBJECT_CREATION
,
GIT_OPT_SET_SSL_CIPHERS
,
GIT_OPT_SET_SSL_CIPHERS
,
GIT_OPT_GET_USER_AGENT
,
}
git_libgit2_opt_t
;
}
git_libgit2_opt_t
;
/**
/**
...
...
src/settings.c
View file @
c18a2bc4
...
@@ -209,6 +209,14 @@ int git_libgit2_opts(int key, ...)
...
@@ -209,6 +209,14 @@ int git_libgit2_opts(int key, ...)
#endif
#endif
break
;
break
;
case
GIT_OPT_GET_USER_AGENT
:
{
git_buf
*
out
=
va_arg
(
ap
,
git_buf
*
);
git_buf_sanitize
(
out
);
error
=
git_buf_sets
(
out
,
git__user_agent
);
}
break
;
default:
default:
giterr_set
(
GITERR_INVALID
,
"invalid option key"
);
giterr_set
(
GITERR_INVALID
,
"invalid option key"
);
error
=
-
1
;
error
=
-
1
;
...
...
tests/core/useragent.c
View file @
c18a2bc4
...
@@ -4,8 +4,14 @@
...
@@ -4,8 +4,14 @@
void
test_core_useragent__get
(
void
)
void
test_core_useragent__get
(
void
)
{
{
const
char
*
custom_name
=
"super duper git"
;
const
char
*
custom_name
=
"super duper git"
;
git_buf
buf
=
GIT_BUF_INIT
;
cl_assert_equal_p
(
NULL
,
git_libgit2__user_agent
());
cl_assert_equal_p
(
NULL
,
git_libgit2__user_agent
());
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_SET_USER_AGENT
,
custom_name
));
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_SET_USER_AGENT
,
custom_name
));
cl_assert_equal_s
(
custom_name
,
git_libgit2__user_agent
());
cl_assert_equal_s
(
custom_name
,
git_libgit2__user_agent
());
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_GET_USER_AGENT
,
&
buf
));
cl_assert_equal_s
(
custom_name
,
buf
.
ptr
);
git_buf_free
(
&
buf
);
}
}
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