]> git.ipfire.org Git - thirdparty/git.git/blob - version.c
Merge branch 'jc/maint-blame-no-such-path' into maint
[thirdparty/git.git] / version.c
1 #include "git-compat-util.h"
2 #include "version.h"
3 #include "strbuf.h"
4
5 const char git_version_string[] = GIT_VERSION;
6
7 const char *git_user_agent(void)
8 {
9 static const char *agent = NULL;
10
11 if (!agent) {
12 agent = getenv("GIT_USER_AGENT");
13 if (!agent)
14 agent = GIT_USER_AGENT;
15 }
16
17 return agent;
18 }
19
20 const char *git_user_agent_sanitized(void)
21 {
22 static const char *agent = NULL;
23
24 if (!agent) {
25 struct strbuf buf = STRBUF_INIT;
26 int i;
27
28 strbuf_addstr(&buf, git_user_agent());
29 strbuf_trim(&buf);
30 for (i = 0; i < buf.len; i++) {
31 if (buf.buf[i] <= 32 || buf.buf[i] >= 127)
32 buf.buf[i] = '.';
33 }
34 agent = buf.buf;
35 }
36
37 return agent;
38 }