Start preparing for 1.8.4.2
[alt-git.git] / version.c
blob6106a8098c8a46575f9afae5da9909b5c196f754
1 #include "git-compat-util.h"
2 #include "version.h"
3 #include "strbuf.h"
5 const char git_version_string[] = GIT_VERSION;
7 const char *git_user_agent(void)
9 static const char *agent = NULL;
11 if (!agent) {
12 agent = getenv("GIT_USER_AGENT");
13 if (!agent)
14 agent = GIT_USER_AGENT;
17 return agent;
20 const char *git_user_agent_sanitized(void)
22 static const char *agent = NULL;
24 if (!agent) {
25 struct strbuf buf = STRBUF_INIT;
26 int i;
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] = '.';
34 agent = buf.buf;
37 return agent;