Merge branch 'ml/trace'
authorJunio C Hamano <junkio@cox.net>
Thu, 13 Jul 2006 06:09:10 +0000 (23:09 -0700)
committerJunio C Hamano <junkio@cox.net>
Thu, 13 Jul 2006 06:09:10 +0000 (23:09 -0700)
* ml/trace:
test-lib: unset GIT_TRACE
GIT_TRACE: fix a mixed declarations and code warning
GIT_TRACE: show which built-in/external commands are executed

1  2 
Documentation/git.txt
git.c
t/test-lib.sh
diff --combined Documentation/git.txt
index d00cc3ea5219f73aac79709e683e135548555fd3,4b140b8216797941974ba3da8f22c8b021005150..ce3058182fead833c45daf02a2806f151b15f61f
@@@ -478,7 -478,7 +478,7 @@@ Configuration Mechanis
  
  Starting from 0.99.9 (actually mid 0.99.8.GIT), `.git/config` file
  is used to hold per-repository configuration options.  It is a
 -simple text file modelled after `.ini` format familiar to some
 +simple text file modeled after `.ini` format familiar to some
  people.  Here is an example:
  
  ------------
@@@ -615,6 -615,13 +615,13 @@@ git Diff
        gitlink:git-diff-files[1];
        gitlink:git-diff-tree[1]
  
+ other
+ ~~~~~
+ 'GIT_TRACE'::
+       If this variable is set git will print `trace:` messages on
+       stderr telling about alias expansion, built-in command
+       execution and external command execution.
  Discussion[[Discussion]]
  ------------------------
  include::README[]
diff --combined git.c
index fee71383c6e6ca0374e8356c8b55570d00f93ea9,27989da77c74a2b55f0f836ba722d4369f975e06..102735af6c0cfb496a04593ba466a9fbb18f693d
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -11,6 -11,7 +11,7 @@@
  #include "git-compat-util.h"
  #include "exec_cmd.h"
  #include "cache.h"
+ #include "quote.h"
  
  #include "builtin.h"
  
@@@ -120,6 -121,18 +121,18 @@@ static int handle_alias(int *argcp, con
                        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*) *
@@@ -188,8 -201,7 +201,8 @@@ static void handle_internal_command(in
                { "stripspace", cmd_stripspace },
                { "update-index", cmd_update_index },
                { "update-ref", cmd_update_ref },
 -              { "fmt-merge-msg", cmd_fmt_merge_msg }
 +              { "fmt-merge-msg", cmd_fmt_merge_msg },
 +              { "prune", cmd_prune },
        };
        int i;
  
                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));
        }
  }
@@@ -252,11 -276,6 +277,11 @@@ int main(int argc, const char **argv, c
                cmd = *++argv;
                argc--;
  
 +              if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
 +                      setup_pager();
 +                      continue;
 +              }
 +
                if (strncmp(cmd, "--", 2))
                        break;
  
diff --combined t/test-lib.sh
index b0d7990a669cb053e5112bd459e9ecaffbd4c504,c3d3984b33f4fb31d228e262a54a4b121e90d4b2..470a909891bc1358163af91513972ce7d0c702c0
@@@ -9,8 -9,6 +9,8 @@@ LC_ALL=
  PAGER=cat
  TZ=UTC
  export LANG LC_ALL PAGER TZ
 +EDITOR=:
 +VISUAL=:
  unset AUTHOR_DATE
  unset AUTHOR_EMAIL
  unset AUTHOR_NAME
@@@ -28,11 -26,11 +28,12 @@@ unset GIT_DI
  unset GIT_EXTERNAL_DIFF
  unset GIT_INDEX_FILE
  unset GIT_OBJECT_DIRECTORY
+ unset GIT_TRACE
  unset SHA1_FILE_DIRECTORIES
  unset SHA1_FILE_DIRECTORY
  export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
  export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
 +export EDITOR VISUAL
  
  # Each test should start with something like this, after copyright notices:
  #