{"thread":{"id":"40560","subject":"[PATCH] Tracing commands includes its working directory","startedAt":"2015-10-14T21:24:17Z","lastAt":"2015-10-14T21:45:39Z","messageCount":2,"participants":["Stefan Beller","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"271700","messageId":"1444857857-25796-1-git-send-email-sbeller@google.com","threadId":"40560","inReplyTo":null,"subject":"[PATCH] Tracing commands includes its working directory","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-10-14T21:24:17Z","receivedAt":"2015-10-14T21:24:17Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Specially when having concurrent flows of command execution,\nthe order of commands printed cannot be relied upon. To aid\nthe poor developer follow the flow of commands include the\ncurrent working directory in which the command is carried out.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n exec_cmd.c    | 2 +-\n git.c         | 8 ++++----\n run-command.c | 4 ++--\n 3 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex e85f0fd..bb79933 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -125,7 +125,7 @@ const char **prepare_git_cmd(const char **argv)\n \n int execv_git_cmd(const char **argv) {\n \tconst char **nargv = prepare_git_cmd(argv);\n-\ttrace_argv_printf(nargv, \"trace: exec:\");\n+\ttrace_argv_printf(nargv, \"(%s) trace: exec:\", xgetcwd());\n \n \t/* execvp() can only ever return if it fails */\n \tsane_execvp(\"git\", (char **)nargv);\ndiff --git a/git.c b/git.c\nindex deecba0..e077e2d 100644\n--- a/git.c\n+++ b/git.c\n@@ -278,8 +278,8 @@ static int handle_alias(int *argcp, const char ***argv)\n \t\t\tdie(\"recursive alias: %s\", alias_command);\n \n \t\ttrace_argv_printf(new_argv,\n-\t\t\t\t  \"trace: alias expansion: %s =>\",\n-\t\t\t\t  alias_command);\n+\t\t\t\t  \"(%s) trace: alias expansion: %s =>\",\n+\t\t\t\t  xgetcwd(), alias_command);\n \n \t\tREALLOC_ARRAY(new_argv, count + *argcp);\n \t\t/* insert after command name */\n@@ -345,7 +345,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n \tif (!help && p->option & NEED_WORK_TREE)\n \t\tsetup_work_tree();\n \n-\ttrace_argv_printf(argv, \"trace: built-in: git\");\n+\ttrace_argv_printf(argv, \"(%s) trace: built-in: git\", xgetcwd());\n \n \tstatus = p->fn(argc, argv, prefix);\n \tif (status)\n@@ -557,7 +557,7 @@ static void execv_dashed_external(const char **argv)\n \ttmp = argv[0];\n \targv[0] = cmd.buf;\n \n-\ttrace_argv_printf(argv, \"trace: exec:\");\n+\ttrace_argv_printf(argv, \"(%s) trace: exec:\", xgetcwd());\n \n \t/*\n \t * if we fail because the command is not found, it is\ndiff --git a/run-command.c b/run-command.c\nindex ef3da27..e483bae 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -194,7 +194,7 @@ static const char **prepare_shell_cmd(const char **argv)\n static int execv_shell_cmd(const char **argv)\n {\n \tconst char **nargv = prepare_shell_cmd(argv);\n-\ttrace_argv_printf(nargv, \"trace: exec:\");\n+\ttrace_argv_printf(nargv, \"(%s) trace: exec:\", xgetcwd());\n \tsane_execvp(nargv[0], (char **)nargv);\n \tfree(nargv);\n \treturn -1;\n@@ -346,7 +346,7 @@ fail_pipe:\n \t\tcmd->err = fderr[0];\n \t}\n \n-\ttrace_argv_printf(cmd->argv, \"trace: run_command:\");\n+\ttrace_argv_printf(cmd->argv, \"(%s) trace: run_command:\", xgetcwd());\n \tfflush(NULL);\n \n #ifndef GIT_WINDOWS_NATIVE\n-- \n2.5.0.267.g8d6e698.dirty\n"},{"id":"271702","messageId":"xmqqbnc16s58.fsf@gitster.mtv.corp.google.com","threadId":"40560","inReplyTo":"1444857857-25796-1-git-send-email-sbeller@google.com","subject":"Re: [PATCH] Tracing commands includes its working directory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-10-14T21:45:39Z","receivedAt":"2015-10-14T21:45:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> Specially when having concurrent flows of command execution,\n> the order of commands printed cannot be relied upon. To aid\n> the poor developer follow the flow of commands include the\n> current working directory in which the command is carried out.\n>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n\nI am not quite sure about the motivation behind this patch.  If you\nare doing N processes, each of which *happens* to be working inside\nits own directory that is different from all others, then it may be\na usable way to tell them apart, but that smells like too much of\nspecial casing that will be applicable ohly to what you happen to be\ndeveloping recently and nowhere else.  Some of these N processes\nshare the same cwd in an application different from yours.\n\nOne way to tweak it to be generic enough may be to show a trace\noutput when git goes into a different working directory, which is a\nsignificant event that is worth tracing, and then have a mode where\nall trace lines are prefixed with process ID, perhaps?\n\n>  exec_cmd.c    | 2 +-\n>  git.c         | 8 ++++----\n>  run-command.c | 4 ++--\n>  3 files changed, 7 insertions(+), 7 deletions(-)\n>\n> diff --git a/exec_cmd.c b/exec_cmd.c\n> index e85f0fd..bb79933 100644\n> --- a/exec_cmd.c\n> +++ b/exec_cmd.c\n> @@ -125,7 +125,7 @@ const char **prepare_git_cmd(const char **argv)\n>  \n>  int execv_git_cmd(const char **argv) {\n>  \tconst char **nargv = prepare_git_cmd(argv);\n> -\ttrace_argv_printf(nargv, \"trace: exec:\");\n> +\ttrace_argv_printf(nargv, \"(%s) trace: exec:\", xgetcwd());\n>  \n>  \t/* execvp() can only ever return if it fails */\n>  \tsane_execvp(\"git\", (char **)nargv);\n> diff --git a/git.c b/git.c\n> index deecba0..e077e2d 100644\n> --- a/git.c\n> +++ b/git.c\n> @@ -278,8 +278,8 @@ static int handle_alias(int *argcp, const char ***argv)\n>  \t\t\tdie(\"recursive alias: %s\", alias_command);\n>  \n>  \t\ttrace_argv_printf(new_argv,\n> -\t\t\t\t  \"trace: alias expansion: %s =>\",\n> -\t\t\t\t  alias_command);\n> +\t\t\t\t  \"(%s) trace: alias expansion: %s =>\",\n> +\t\t\t\t  xgetcwd(), alias_command);\n>  \n>  \t\tREALLOC_ARRAY(new_argv, count + *argcp);\n>  \t\t/* insert after command name */\n> @@ -345,7 +345,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n>  \tif (!help && p->option & NEED_WORK_TREE)\n>  \t\tsetup_work_tree();\n>  \n> -\ttrace_argv_printf(argv, \"trace: built-in: git\");\n> +\ttrace_argv_printf(argv, \"(%s) trace: built-in: git\", xgetcwd());\n>  \n>  \tstatus = p->fn(argc, argv, prefix);\n>  \tif (status)\n> @@ -557,7 +557,7 @@ static void execv_dashed_external(const char **argv)\n>  \ttmp = argv[0];\n>  \targv[0] = cmd.buf;\n>  \n> -\ttrace_argv_printf(argv, \"trace: exec:\");\n> +\ttrace_argv_printf(argv, \"(%s) trace: exec:\", xgetcwd());\n>  \n>  \t/*\n>  \t * if we fail because the command is not found, it is\n> diff --git a/run-command.c b/run-command.c\n> index ef3da27..e483bae 100644\n> --- a/run-command.c\n> +++ b/run-command.c\n> @@ -194,7 +194,7 @@ static const char **prepare_shell_cmd(const char **argv)\n>  static int execv_shell_cmd(const char **argv)\n>  {\n>  \tconst char **nargv = prepare_shell_cmd(argv);\n> -\ttrace_argv_printf(nargv, \"trace: exec:\");\n> +\ttrace_argv_printf(nargv, \"(%s) trace: exec:\", xgetcwd());\n>  \tsane_execvp(nargv[0], (char **)nargv);\n>  \tfree(nargv);\n>  \treturn -1;\n> @@ -346,7 +346,7 @@ fail_pipe:\n>  \t\tcmd->err = fderr[0];\n>  \t}\n>  \n> -\ttrace_argv_printf(cmd->argv, \"trace: run_command:\");\n> +\ttrace_argv_printf(cmd->argv, \"(%s) trace: run_command:\", xgetcwd());\n>  \tfflush(NULL);\n>  \n>  #ifndef GIT_WINDOWS_NATIVE\n"}]}