summaryrefslogtreecommitdiff
path: root/exec_cmd.c
diff options
context:
space:
mode:
authorMatthias Lederhofer <matled@gmx.net>2006-06-25 15:56:18 +0200
committerJunio C Hamano <junkio@cox.net>2006-07-09 00:57:23 -0700
commit575ba9d69d5dfd07d95343fe946a5991c4cb27d6 (patch)
tree8f9f3ca832249b98c3621a09035baba2e1ce385f /exec_cmd.c
parent88f0d5d7d95f815d2e8a36a8ceb7459dbd90992c (diff)
downloadgit-575ba9d69d5dfd07d95343fe946a5991c4cb27d6.tar.gz
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>
Diffstat (limited to 'exec_cmd.c')
-rw-r--r--exec_cmd.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/exec_cmd.c b/exec_cmd.c
index c1539d12ce..f2133ec93f 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -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;