]> git.ipfire.org Git - thirdparty/git.git/blame - version.c
GIT-VERSION-GEN: support non-standard $GIT_DIR path
[thirdparty/git.git] / version.c
CommitLineData
816fb46b
JK
1#include "git-compat-util.h"
2#include "version.h"
ff5effdf 3#include "strbuf.h"
816fb46b
JK
4
5const char git_version_string[] = GIT_VERSION;
42dcbb73
JK
6
7const 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}
ff5effdf
JK
19
20const 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}