Staging
v0.5.1
https://github.com/git/git
Revision ab15ad1a3b4b04a29415aef8c9afa2f64fc194a2 authored by Junio C Hamano on 13 May 2019, 14:40:13 UTC, committed by Junio C Hamano on 13 May 2019, 14:50:35 UTC
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 49bc8ce
Raw File
Tip revision: ab15ad1a3b4b04a29415aef8c9afa2f64fc194a2 authored by Junio C Hamano on 13 May 2019, 14:40:13 UTC
Git 2.22-rc0
Tip revision: ab15ad1
version.c
#include "git-compat-util.h"
#include "version.h"
#include "strbuf.h"

const char git_version_string[] = GIT_VERSION;
const char git_built_from_commit_string[] = GIT_BUILT_FROM_COMMIT;

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