add GIT_SHALLOW_FILE to propagate --shallow-file to subprocesses
This may be needed when a hook is run after a new shallow pack is received, but .git/shallow is not settled yet. A temporary shallow file to plug all loose ends should be used instead. GIT_SHALLOW_FILE is overriden by --shallow-file. --shallow-file does not work in this case because the hook may spawn many git subprocesses and the launch commands do not have --shallow-file as it's a recent addition. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
5dbd767601
commit
069c053222
@ -10,6 +10,7 @@
|
||||
#include "cache.h"
|
||||
#include "refs.h"
|
||||
#include "fmt-merge-msg.h"
|
||||
#include "commit.h"
|
||||
|
||||
int trust_executable_bit = 1;
|
||||
int trust_ctime = 1;
|
||||
@ -97,6 +98,7 @@ const char * const local_repo_env[] = {
|
||||
INDEX_ENVIRONMENT,
|
||||
NO_REPLACE_OBJECTS_ENVIRONMENT,
|
||||
GIT_PREFIX_ENVIRONMENT,
|
||||
GIT_SHALLOW_FILE_ENVIRONMENT,
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -124,6 +126,7 @@ static char *expand_namespace(const char *raw_namespace)
|
||||
static void setup_git_env(void)
|
||||
{
|
||||
const char *gitfile;
|
||||
const char *shallow_file;
|
||||
|
||||
git_dir = getenv(GIT_DIR_ENVIRONMENT);
|
||||
if (!git_dir)
|
||||
@ -147,6 +150,9 @@ static void setup_git_env(void)
|
||||
read_replace_refs = 0;
|
||||
namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));
|
||||
namespace_len = strlen(namespace);
|
||||
shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);
|
||||
if (shallow_file)
|
||||
set_alternate_shallow_file(shallow_file, 0);
|
||||
}
|
||||
|
||||
int is_bare_repository(void)
|
||||
|
Reference in New Issue
Block a user