Revision 7dde48ea7aa18de1174628e21510967b0ad71d7c authored by Junio C Hamano on 19 May 2014, 17:35:36 UTC, committed by Junio C Hamano on 19 May 2014, 17:35:36 UTC
* lt/request-pull:
  request-pull: resurrect for-linus -> tags/for-linus DWIM
2 parent s 5714722 + d952cbb
Raw File
version.c
#include "git-compat-util.h"
#include "version.h"
#include "strbuf.h"

const char git_version_string[] = GIT_VERSION;

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;
}

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;
}
back to top