2012-06-02 18:51:42 +00:00
|
|
|
#include "git-compat-util.h"
|
|
|
|
#include "version.h"
|
2012-08-03 16:19:16 +00:00
|
|
|
#include "strbuf.h"
|
2012-06-02 18:51:42 +00:00
|
|
|
|
|
|
|
const char git_version_string[] = GIT_VERSION;
|
2012-06-02 19:01:12 +00:00
|
|
|
|
|
|
|
const char *git_user_agent(void)
|
|
|
|
{
|
|
|
|
static const char *agent = NULL;
|
|
|
|
|
|
|
|
if (!agent) {
|
|
|
|
agent = getenv("GIT_USER_AGENT");
|
|
|
|
if (!agent)
|
|
|
|
agent = GIT_USER_AGENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return agent;
|
|
|
|
}
|
2012-08-03 16:19:16 +00:00
|
|
|
|
|
|
|
const char *git_user_agent_sanitized(void)
|
|
|
|
{
|
|
|
|
static const char *agent = NULL;
|
|
|
|
|
|
|
|
if (!agent) {
|
|
|
|
struct strbuf buf = STRBUF_INIT;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
strbuf_addstr(&buf, git_user_agent());
|
|
|
|
strbuf_trim(&buf);
|
|
|
|
for (i = 0; i < buf.len; i++) {
|
|
|
|
if (buf.buf[i] <= 32 || buf.buf[i] >= 127)
|
|
|
|
buf.buf[i] = '.';
|
|
|
|
}
|
|
|
|
agent = buf.buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
return agent;
|
|
|
|
}
|