git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Tracing commands includes its working directory

From
Stefan Beller <sbeller@google.com>
Date
Oct 14, 2015, 21:24 UTC
Message-ID
<1444857857-25796-1-git-send-email-sbeller@google.com>

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@google.com>
---
 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
Next: Junio C Hamano
Message 1 of 2 in “Tracing commands includes its working directory”
  1. Tracing commands includes its working directoryStefan Beller, Oct 14, 2015
  2. Junio C HamanoOct 14, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.