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
@ -13,10 +13,12 @@ static int is_shallow = -1;
|
||||
static struct stat shallow_stat;
|
||||
static char *alternate_shallow_file;
|
||||
|
||||
void set_alternate_shallow_file(const char *path)
|
||||
void set_alternate_shallow_file(const char *path, int override)
|
||||
{
|
||||
if (is_shallow != -1)
|
||||
die("BUG: is_repository_shallow must not be called before set_alternate_shallow_file");
|
||||
if (alternate_shallow_file && !override)
|
||||
return;
|
||||
free(alternate_shallow_file);
|
||||
alternate_shallow_file = path ? xstrdup(path) : NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user