
Start working to make the codebase buildable with -Wsign-compare. * ps/build-sign-compare: t/helper: don't depend on implicit wraparound scalar: address -Wsign-compare warnings builtin/patch-id: fix type of `get_one_patchid()` builtin/blame: fix type of `length` variable when emitting object ID gpg-interface: address -Wsign-comparison warnings daemon: fix type of `max_connections` daemon: fix loops that have mismatching integer types global: trivial conversions to fix `-Wsign-compare` warnings pkt-line: fix -Wsign-compare warning on 32 bit platform csum-file: fix -Wsign-compare warning on 32-bit platform diff.h: fix index used to loop through unsigned integer config.mak.dev: drop `-Wno-sign-compare` global: mark code units that generate warnings with `-Wsign-compare` compat/win32: fix -Wsign-compare warning in "wWinMain()" compat/regex: explicitly ignore "-Wsign-compare" warnings git-compat-util: introduce macros to disable "-Wsign-compare" warnings
40 lines
741 B
C
40 lines
741 B
C
#include "git-compat-util.h"
|
|
#include "version.h"
|
|
#include "version-def.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;
|
|
|
|
strbuf_addstr(&buf, git_user_agent());
|
|
strbuf_trim(&buf);
|
|
for (size_t i = 0; i < buf.len; i++) {
|
|
if (buf.buf[i] <= 32 || buf.buf[i] >= 127)
|
|
buf.buf[i] = '.';
|
|
}
|
|
agent = buf.buf;
|
|
}
|
|
|
|
return agent;
|
|
}
|