Tracing commands includes its working directory
PATCH 1/1 Tracing commands includes its working directory
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.
--- exec_cmd.c | 2 +- git.c | 8 ++++---- run-command.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
exec_cmd.c +1 -1
@@ -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);
git.c +4 -4
@@ -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
run-command.c +2 -2
@@ -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
Signature · 1 line
2.5.0.267.g8d6e698.dirty
Quoted 7 lines · Stefan Beller
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 <[email protected]>---
I am not quite sure about the motivation behind this patch. If you are doing N processes, each of which *happens* to be working inside its own directory that is different from all others, then it may be a usable way to tell them apart, but that smells like too much of special casing that will be applicable ohly to what you happen to be developing recently and nowhere else. Some of these N processes share the same cwd in an application different from yours.
One way to tweak it to be generic enough may be to show a trace output when git goes into a different working directory, which is a significant event that is worth tracing, and then have a mode where all trace lines are prefixed with process ID, perhaps?
Quoted 73 lines
exec_cmd.c | 2 +- git.c | 8 ++++---- run-command.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)exec_cmd.c +1
-1@@ -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);git.c +4
-4@@ -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 run-command.c +2
-2@@ -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