GIT_TRACE: show which built-in/external commands are executed

With the environment variable GIT_TRACE set git will show
 - alias expansion
 - built-in command execution
 - external command execution
on stderr.

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Matthias Lederhofer
2006-06-25 15:56:18 +02:00
committed by Junio C Hamano
parent 88f0d5d7d9
commit 575ba9d69d
5 changed files with 69 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#include "cache.h"
#include "exec_cmd.h"
#include "quote.h"
#define MAX_ARGS 32
extern char **environ;
@ -96,9 +97,27 @@ int execv_git_cmd(const char **argv)
tmp = argv[0];
argv[0] = git_command;
if (getenv("GIT_TRACE")) {
fputs("trace: exec:", stderr);
const char **p = argv;
while (*p) {
fputc(' ', stderr);
sq_quote_print(stderr, *p);
++p;
}
putc('\n', stderr);
fflush(stderr);
}
/* execve() can only ever return if it fails */
execve(git_command, (char **)argv, environ);
if (getenv("GIT_TRACE")) {
fprintf(stderr, "trace: exec failed: %s\n",
strerror(errno));
fflush(stderr);
}
argv[0] = tmp;
}
return -1;