]> git.ipfire.org Git - thirdparty/git.git/commit
setup: trace bare repository setups
authorGlen Choo <chooglen@google.com>
Mon, 1 May 2023 17:30:37 +0000 (10:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 May 2023 18:20:33 +0000 (11:20 -0700)
commite35f202b4503256db148ad61487fe13aa75960f2
treee5b0424fbe35eca25ee2b35888d3f2e65332018f
parent48d89b51b3bb8a60580c36731b96a7206ce1e5b9
setup: trace bare repository setups

safe.bareRepository=explicit is a safer default mode of operation, since
it guards against the embedded bare repository attack [1]. Most end
users don't use bare repositories directly, so they should be able to
set safe.bareRepository=explicit, with the expectation that they can
reenable bare repositories by specifying GIT_DIR or --git-dir.

However, the user might use a tool that invokes Git on bare repositories
without setting GIT_DIR (e.g. "go mod" will clone bare repositories
[2]), so even if a user wanted to use safe.bareRepository=explicit, it
wouldn't be feasible until their tools learned to set GIT_DIR.

To make this transition easier, add a trace message to note when we
attempt to set up a bare repository without setting GIT_DIR. This allows
users and tool developers to audit which of their tools are problematic
and report/fix the issue.  When they are sufficiently confident, they
would switch over to "safe.bareRepository=explicit".

Note that this uses trace2_data_string(), which isn't supported by the
"normal" GIT_TRACE2 target, only _EVENT or _PERF.

[1] https://lore.kernel.org/git/kl6lsfqpygsj.fsf@chooglen-macbookpro.roam.corp.google.com/
[2] https://go.dev/ref/mod

Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup.c
t/t0035-safe-bare-repository.sh