aboutsummaryrefslogtreecommitdiff
path: root/git.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 /git.c
parent88f0d5d7d95f815d2e8a36a8ceb7459dbd90992c (diff)
downloadgit-575ba9d69d5dfd07d95343fe946a5991c4cb27d6.tar.gz
git-575ba9d69d5dfd07d95343fe946a5991c4cb27d6.tar.xz
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 'git.c')
-rw-r--r--git.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/git.c b/git.c
index 256730112..27989da77 100644
--- a/git.c
+++ b/git.c
@@ -11,6 +11,7 @@
#include "git-compat-util.h"
#include "exec_cmd.h"
#include "cache.h"
+#include "quote.h"
#include "builtin.h"
@@ -120,6 +121,18 @@ static int handle_alias(int *argcp, const char ***argv)
if (!strcmp(alias_command, new_argv[0]))
die("recursive alias: %s", alias_command);
+ if (getenv("GIT_TRACE")) {
+ int i;
+ fprintf(stderr, "trace: alias expansion: %s =>",
+ alias_command);
+ for (i = 0; i < count; ++i) {
+ fputc(' ', stderr);
+ sq_quote_print(stderr, new_argv[i]);
+ }
+ fputc('\n', stderr);
+ fflush(stderr);
+ }
+
/* insert after command name */
if (*argcp > 1) {
new_argv = realloc(new_argv, sizeof(char*) *
@@ -202,6 +215,18 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
struct cmd_struct *p = commands+i;
if (strcmp(p->cmd, cmd))
continue;
+
+ if (getenv("GIT_TRACE")) {
+ int i;
+ fprintf(stderr, "trace: built-in: git");
+ for (i = 0; i < argc; ++i) {
+ fputc(' ', stderr);
+ sq_quote_print(stderr, argv[i]);
+ }
+ putc('\n', stderr);
+ fflush(stderr);
+ }
+
exit(p->fn(argc, argv, envp));
}
}