environment: add GIT_PREFIX to local_repo_env

The GIT_PREFIX variable is set based on our location within
the working tree. It should therefore be cleared whenever
GIT_WORK_TREE is cleared.

In practice, this doesn't cause any bugs, because none of
the sub-programs we invoke with local_repo_env cleared
actually care about GIT_PREFIX. But this is the right thing
to do, and future proofs us against that assumption changing.

While we're at it, let's define a GIT_PREFIX_ENVIRONMENT
macro; this avoids repetition of the string literal, which
can help catch any spelling mistakes in the code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King
2013-03-08 04:30:25 -05:00
committed by Junio C Hamano
parent 2163e5dbb4
commit a6f7f9a325
3 changed files with 4 additions and 2 deletions

View File

@ -768,9 +768,9 @@ const char *setup_git_directory_gently(int *nongit_ok)
prefix = setup_git_directory_gently_1(nongit_ok);
if (prefix)
setenv("GIT_PREFIX", prefix, 1);
setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
else
setenv("GIT_PREFIX", "", 1);
setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
if (startup_info) {
startup_info->have_repository = !nongit_ok || !*nongit_ok;