[PATCH] Tracing commands includes its working directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Specially when having concurrent flows of command execution,
the order of commands printed cannot be relied upon. To aid
the poor developer follow the flow of commands include the
current working directory in which the command is carried out.

Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
---
 exec_cmd.c    | 2 +-
 git.c         | 8 ++++----
 run-command.c | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/exec_cmd.c b/exec_cmd.c
index e85f0fd..bb79933 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -125,7 +125,7 @@ const char **prepare_git_cmd(const char **argv)
 
 int execv_git_cmd(const char **argv) {
 	const char **nargv = prepare_git_cmd(argv);
-	trace_argv_printf(nargv, "trace: exec:");
+	trace_argv_printf(nargv, "(%s) trace: exec:", xgetcwd());
 
 	/* execvp() can only ever return if it fails */
 	sane_execvp("git", (char **)nargv);
diff --git a/git.c b/git.c
index deecba0..e077e2d 100644
--- a/git.c
+++ b/git.c
@@ -278,8 +278,8 @@ static int handle_alias(int *argcp, const char ***argv)
 			die("recursive alias: %s", alias_command);
 
 		trace_argv_printf(new_argv,
-				  "trace: alias expansion: %s =>",
-				  alias_command);
+				  "(%s) trace: alias expansion: %s =>",
+				  xgetcwd(), alias_command);
 
 		REALLOC_ARRAY(new_argv, count + *argcp);
 		/* insert after command name */
@@ -345,7 +345,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 	if (!help && p->option & NEED_WORK_TREE)
 		setup_work_tree();
 
-	trace_argv_printf(argv, "trace: built-in: git");
+	trace_argv_printf(argv, "(%s) trace: built-in: git", xgetcwd());
 
 	status = p->fn(argc, argv, prefix);
 	if (status)
@@ -557,7 +557,7 @@ static void execv_dashed_external(const char **argv)
 	tmp = argv[0];
 	argv[0] = cmd.buf;
 
-	trace_argv_printf(argv, "trace: exec:");
+	trace_argv_printf(argv, "(%s) trace: exec:", xgetcwd());
 
 	/*
 	 * if we fail because the command is not found, it is
diff --git a/run-command.c b/run-command.c
index ef3da27..e483bae 100644
--- a/run-command.c
+++ b/run-command.c
@@ -194,7 +194,7 @@ static const char **prepare_shell_cmd(const char **argv)
 static int execv_shell_cmd(const char **argv)
 {
 	const char **nargv = prepare_shell_cmd(argv);
-	trace_argv_printf(nargv, "trace: exec:");
+	trace_argv_printf(nargv, "(%s) trace: exec:", xgetcwd());
 	sane_execvp(nargv[0], (char **)nargv);
 	free(nargv);
 	return -1;
@@ -346,7 +346,7 @@ fail_pipe:
 		cmd->err = fderr[0];
 	}
 
-	trace_argv_printf(cmd->argv, "trace: run_command:");
+	trace_argv_printf(cmd->argv, "(%s) trace: run_command:", xgetcwd());
 	fflush(NULL);
 
 #ifndef GIT_WINDOWS_NATIVE
-- 
2.5.0.267.g8d6e698.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]