run-command.c: print env vars in trace_run_command()

Occasionally submodule code could execute new commands with GIT_DIR set
to some submodule. GIT_TRACE prints just the command line which makes it
hard to tell that it's not really executed on this repository.

Print the env delta (compared to parent environment) in this case.

Helped-by: Junio C Hamano <gitster@pobox.com>
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:
Nguyễn Thái Ngọc Duy
2018-01-18 16:45:11 +07:00
committed by Junio C Hamano
parent 21dfc5e08f
commit c61a975df1
3 changed files with 109 additions and 0 deletions

View File

@ -54,6 +54,15 @@ int cmd_main(int argc, const char **argv)
struct child_process proc = CHILD_PROCESS_INIT;
int jobs;
if (argc < 3)
return 1;
while (!strcmp(argv[1], "env")) {
if (!argv[2])
die("env specifier without a value");
argv_array_push(&proc.env_array, argv[2]);
argv += 2;
argc -= 2;
}
if (argc < 3)
return 1;
proc.argv = (const char **)argv + 2;