Merge branch 'po/git-help-on-git-itself'
authorJunio C Hamano <gitster@pobox.com>
Mon, 17 Jun 2019 17:15:19 +0000 (10:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Jun 2019 17:15:19 +0000 (10:15 -0700)
"git help git" was hard to discover (well, at least for some
people).

* po/git-help-on-git-itself:
Doc: git.txt: remove backticks from link and add git-scm.com/docs
git.c: show usage for accessing the git(1) help page

1  2 
Documentation/git.txt
git.c
diff --combined Documentation/git.txt
index 6ddc1e2ca6830ac165543dad4a57afd6d4b50c49,3a32572847d166354027d6fba58cc2b942fc2c61..f9b09db89b83b9be12c4fdce856b4be822db23f0
@@@ -33,7 -33,8 +33,8 @@@ individual Git commands with "git help 
  manual page gives you an overview of the command-line command syntax.
  
  A formatted and hyperlinked copy of the latest Git documentation
- can be viewed at `https://git.github.io/htmldocs/git.html`.
+ can be viewed at https://git.github.io/htmldocs/git.html
+ or https://git-scm.com/docs.
  
  
  OPTIONS
@@@ -536,6 -537,7 +537,6 @@@ othe
        The command-line parameters passed to the configured command are
        determined by the ssh variant.  See `ssh.variant` option in
        linkgit:git-config[1] for details.
 -
  +
  `$GIT_SSH_COMMAND` takes precedence over `$GIT_SSH`, and is interpreted
  by the shell, which allows additional arguments to be included.
@@@ -660,54 -662,6 +661,54 @@@ of clones and fetches
        When a curl trace is enabled (see `GIT_TRACE_CURL` above), do not dump
        data (that is, only dump info lines and headers).
  
 +`GIT_TRACE2`::
 +      Enables more detailed trace messages from the "trace2" library.
 +      Output from `GIT_TRACE2` is a simple text-based format for human
 +      readability.
 ++
 +If this variable is set to "1", "2" or "true" (comparison
 +is case insensitive), trace messages will be printed to
 +stderr.
 ++
 +If the variable is set to an integer value greater than 2
 +and lower than 10 (strictly) then Git will interpret this
 +value as an open file descriptor and will try to write the
 +trace messages into this file descriptor.
 ++
 +Alternatively, if the variable is set to an absolute path
 +(starting with a '/' character), Git will interpret this
 +as a file path and will try to append the trace messages
 +to it.  If the path already exists and is a directory, the
 +trace messages will be written to files (one per process)
 +in that directory, named according to the last component
 +of the SID and an optional counter (to avoid filename
 +collisions).
 ++
 +In addition, if the variable is set to
 +`af_unix:[<socket_type>:]<absolute-pathname>`, Git will try
 +to open the path as a Unix Domain Socket.  The socket type
 +can be either `stream` or `dgram`.
 ++
 +Unsetting the variable, or setting it to empty, "0" or
 +"false" (case insensitive) disables trace messages.
 ++
 +See link:technical/api-trace2.html[Trace2 documentation]
 +for full details.
 +
 +
 +`GIT_TRACE2_EVENT`::
 +      This setting writes a JSON-based format that is suited for machine
 +      interpretation.
 +      See `GIT_TRACE2` for available trace output options and
 +      link:technical/api-trace2.html[Trace2 documentation] for full details.
 +
 +`GIT_TRACE2_PERF`::
 +      In addition to the text-based messages available in `GIT_TRACE2`, this
 +      setting writes a column-based format for understanding nesting
 +      regions.
 +      See `GIT_TRACE2` for available trace output options and
 +      link:technical/api-trace2.html[Trace2 documentation] for full details.
 +
  `GIT_REDACT_COOKIES`::
        This can be set to a comma-separated list of strings. When a curl trace
        is enabled (see `GIT_TRACE_CURL` above), whenever a "Cookies:" header
diff --combined git.c
index 1bf9c94550d9c232de2f89ef0f2b5a661e43cd79,08b0dbdca9aef7bf8297557523ee4db3c03b0233..c2eec470c956c597aef77ff7d3632994986db00f
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -33,7 -33,8 +33,8 @@@ const char git_usage_string[] 
  const char git_more_info_string[] =
        N_("'git help -a' and 'git help -g' list available subcommands and some\n"
           "concept guides. See 'git help <command>' or 'git help <concept>'\n"
-          "to read about a specific subcommand or concept.");
+          "to read about a specific subcommand or concept.\n"
+          "See 'git help git' for an overview of the system.");
  
  static int use_pager = -1;
  
@@@ -62,13 -63,6 +63,13 @@@ static int list_cmds(const char *spec
  {
        struct string_list list = STRING_LIST_INIT_DUP;
        int i;
 +      int nongit;
 +
 +      /*
 +      * Set up the repository so we can pick up any repo-level config (like
 +      * completion.commands).
 +      */
 +      setup_git_directory_gently(&nongit);
  
        while (*spec) {
                const char *sep = strchrnul(spec, ',');
@@@ -154,20 -148,16 +155,20 @@@ static int handle_options(const char **
                                git_set_exec_path(cmd + 1);
                        else {
                                puts(git_exec_path());
 +                              trace2_cmd_name("_query_");
                                exit(0);
                        }
                } else if (!strcmp(cmd, "--html-path")) {
                        puts(system_path(GIT_HTML_PATH));
 +                      trace2_cmd_name("_query_");
                        exit(0);
                } else if (!strcmp(cmd, "--man-path")) {
                        puts(system_path(GIT_MAN_PATH));
 +                      trace2_cmd_name("_query_");
                        exit(0);
                } else if (!strcmp(cmd, "--info-path")) {
                        puts(system_path(GIT_INFO_PATH));
 +                      trace2_cmd_name("_query_");
                        exit(0);
                } else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
                        use_pager = 1;
                        (*argv)++;
                        (*argc)--;
                } else if (skip_prefix(cmd, "--list-cmds=", &cmd)) {
 +                      trace2_cmd_name("_query_");
                        if (!strcmp(cmd, "parseopt")) {
                                struct string_list list = STRING_LIST_INIT_DUP;
                                int i;
@@@ -344,14 -333,9 +345,14 @@@ static int handle_alias(int *argcp, con
                        commit_pager_choice();
  
                        child.use_shell = 1;
 +                      child.trace2_child_class = "shell_alias";
                        argv_array_push(&child.args, alias_string + 1);
                        argv_array_pushv(&child.args, (*argv) + 1);
  
 +                      trace2_cmd_alias(alias_command, child.args.argv);
 +                      trace2_cmd_list_config();
 +                      trace2_cmd_name("_run_shell_alias_");
 +
                        ret = run_command(&child);
                        if (ret >= 0)   /* normal exit */
                                exit(ret);
                /* insert after command name */
                memcpy(new_argv + count, *argv + 1, sizeof(char *) * *argcp);
  
 +              trace2_cmd_alias(alias_command, new_argv);
 +              trace2_cmd_list_config();
 +
                *argv = new_argv;
                *argcp += count - 1;
  
@@@ -437,8 -418,6 +438,8 @@@ static int run_builtin(struct cmd_struc
                setup_work_tree();
  
        trace_argv_printf(argv, "trace: built-in: git");
 +      trace2_cmd_name(p->cmd);
 +      trace2_cmd_list_config();
  
        validate_cache_entries(the_repository->index);
        status = p->fn(argc, argv, prefix);
@@@ -498,7 -477,7 +499,7 @@@ static struct cmd_struct commands[] = 
        { "diff-files", cmd_diff_files, RUN_SETUP | NEED_WORK_TREE | NO_PARSEOPT },
        { "diff-index", cmd_diff_index, RUN_SETUP | NO_PARSEOPT },
        { "diff-tree", cmd_diff_tree, RUN_SETUP | NO_PARSEOPT },
 -      { "difftool", cmd_difftool, RUN_SETUP | NEED_WORK_TREE },
 +      { "difftool", cmd_difftool, RUN_SETUP_GENTLY },
        { "fast-export", cmd_fast_export, RUN_SETUP },
        { "fetch", cmd_fetch, RUN_SETUP },
        { "fetch-pack", cmd_fetch_pack, RUN_SETUP | NO_PARSEOPT },
        { "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
        { "rm", cmd_rm, RUN_SETUP },
        { "send-pack", cmd_send_pack, RUN_SETUP },
 -      { "serve", cmd_serve, RUN_SETUP },
        { "shortlog", cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER },
        { "show", cmd_show, RUN_SETUP },
        { "show-branch", cmd_show_branch, RUN_SETUP },
        { "show-index", cmd_show_index },
        { "show-ref", cmd_show_ref, RUN_SETUP },
        { "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
 +      /*
 +       * NEEDSWORK: Until the builtin stash is thoroughly robust and no
 +       * longer needs redirection to the stash shell script this is kept as
 +       * is, then should be changed to RUN_SETUP | NEED_WORK_TREE
 +       */
 +      { "stash", cmd_stash },
        { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
        { "stripspace", cmd_stripspace },
        { "submodule--helper", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX | NO_PARSEOPT },
@@@ -693,14 -667,7 +694,14 @@@ static void execv_dashed_external(cons
        cmd.clean_on_exit = 1;
        cmd.wait_after_clean = 1;
        cmd.silent_exec_failure = 1;
 +      cmd.trace2_child_class = "dashed";
 +
 +      trace2_cmd_name("_run_dashed_");
  
 +      /*
 +       * The code in run_command() logs trace2 child_start/child_exit
 +       * events, so we do not need to report exec/exec_result events here.
 +       */
        trace_argv_printf(cmd.args.argv, "trace: exec:");
  
        /*
         * the program.
         */
        status = run_command(&cmd);
 +
 +      /*
 +       * If the child process ran and we are now going to exit, emit a
 +       * generic string as our trace2 command verb to indicate that we
 +       * launched a dashed command.
 +       */
        if (status >= 0)
                exit(status);
        else if (errno != ENOENT)
@@@ -741,43 -702,6 +742,43 @@@ static int run_argv(int *argcp, const c
                if (!done_alias)
                        handle_builtin(*argcp, *argv);
  
 +#if 0 // TODO In GFW, need to amend a7924b655e940b06cb547c235d6bed9767929673 to include trace2_ and _tr2 lines.
 +              else if (get_builtin(**argv)) {
 +                      struct argv_array args = ARGV_ARRAY_INIT;
 +                      int i;
 +
 +                      /*
 +                       * The current process is committed to launching a
 +                       * child process to run the command named in (**argv)
 +                       * and exiting.  Log a generic string as the trace2
 +                       * command verb to indicate this.  Note that the child
 +                       * process will log the actual verb when it runs.
 +                       */
 +                      trace2_cmd_name("_run_git_alias_");
 +
 +                      if (get_super_prefix())
 +                              die("%s doesn't support --super-prefix", **argv);
 +
 +                      commit_pager_choice();
 +
 +                      argv_array_push(&args, "git");
 +                      for (i = 0; i < *argcp; i++)
 +                              argv_array_push(&args, (*argv)[i]);
 +
 +                      trace_argv_printf(args.argv, "trace: exec:");
 +
 +                      /*
 +                       * if we fail because the command is not found, it is
 +                       * OK to return. Otherwise, we just pass along the status code.
 +                       */
 +                      i = run_command_v_opt_tr2(args.argv, RUN_SILENT_EXEC_FAILURE |
 +                                                RUN_CLEAN_ON_EXIT, "git_alias");
 +                      if (i >= 0 || errno != ENOENT)
 +                              exit(i);
 +                      die("could not execute builtin %s", **argv);
 +              }
 +#endif // a7924b655e940b06cb547c235d6bed9767929673
 +
                /* .. then try the external ones */
                execv_dashed_external(*argv);