Line | Count | Source (jump to first uncovered line) |
1 | | #include "git-compat-util.h" |
2 | | #include "version.h" |
3 | | #include "strbuf.h" |
4 | | |
5 | | const char git_version_string[] = GIT_VERSION; |
6 | | const char git_built_from_commit_string[] = GIT_BUILT_FROM_COMMIT; |
7 | | |
8 | | const char *git_user_agent(void) |
9 | 0 | { |
10 | 0 | static const char *agent = NULL; |
11 | |
|
12 | 0 | if (!agent) { |
13 | 0 | agent = getenv("GIT_USER_AGENT"); |
14 | 0 | if (!agent) |
15 | 0 | agent = GIT_USER_AGENT; |
16 | 0 | } |
17 | |
|
18 | 0 | return agent; |
19 | 0 | } |
20 | | |
21 | | const char *git_user_agent_sanitized(void) |
22 | 0 | { |
23 | 0 | static const char *agent = NULL; |
24 | |
|
25 | 0 | if (!agent) { |
26 | 0 | struct strbuf buf = STRBUF_INIT; |
27 | 0 | int i; |
28 | |
|
29 | 0 | strbuf_addstr(&buf, git_user_agent()); |
30 | 0 | strbuf_trim(&buf); |
31 | 0 | for (i = 0; i < buf.len; i++) { |
32 | 0 | if (buf.buf[i] <= 32 || buf.buf[i] >= 127) |
33 | 0 | buf.buf[i] = '.'; |
34 | 0 | } |
35 | 0 | agent = buf.buf; |
36 | 0 | } |
37 | |
|
38 | 0 | return agent; |
39 | 0 | } |