如何调试与 git/git-shell 相关的问题?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6178401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:02:32  来源:igfitidea点击:

How can I debug git/git-shell related problems?

gitdebuggingtrace

提问by Andor

How can I have some debug information regarding git/git-shell?

我如何获得一些关于 git/git-shell 的调试信息?

I had a problem, that user1could clone a repository without problem, while user2could clone only an empty one. I had set GIT_TRACE=1, but nothing useful was told.

我有一个问题,它user1可以毫无问题地克隆一个存储库,而user2只能克隆一个空的存储库。我已经设置了GIT_TRACE=1,但没有告诉任何有用的信息。

Finally, after a long trial and error, it turned out that it was a permission problem on a file. An appropriate error message could short-circuit this problem.

最后,经过长时间的反复试验,结果证明是文件的权限问题。适当的错误消息可以解决此问题。

回答by WTK

For even more verbose output use following:

对于更详细的输出,请使用以下内容:

GIT_CURL_VERBOSE=1 GIT_TRACE=1 git pull origin master

GIT_CURL_VERBOSE=1 GIT_TRACE=1 git pull origin master

回答by kenorb

Debugging

调试

Git has a fairly complete set of traces embedded which you can use to debug your git problems.

Git 嵌入了一组相当完整的跟踪,您可以使用它们来调试 git 问题。

To turn them on, you can define the following variables:

要打开它们,您可以定义以下变量:

  • GIT_TRACEfor general traces,
  • GIT_TRACE_PACK_ACCESSfor tracing of packfile access,
  • GIT_TRACE_PACKETfor packet-level tracing for network operations,
  • GIT_TRACE_PERFORMANCEfor logging the performance data,
  • GIT_TRACE_SETUPfor information about discovering the repository and environment it's interacting with,
  • GIT_MERGE_VERBOSITYfor debugging recursive merge strategy (values: 0-5),
  • GIT_CURL_VERBOSEfor logging all curl messages (equivalent to curl -v),
  • GIT_TRACE_SHALLOWfor debugging fetching/cloning of shallow repositories.
  • GIT_TRACE对于一般痕迹,
  • GIT_TRACE_PACK_ACCESS用于跟踪包文件访问,
  • GIT_TRACE_PACKET用于网络操作的数据包级跟踪,
  • GIT_TRACE_PERFORMANCE用于记录性能数据,
  • GIT_TRACE_SETUP有关发现与其交互的存储库和环境的信息,
  • GIT_MERGE_VERBOSITY用于调试递归合并策略(值:0-5),
  • GIT_CURL_VERBOSE用于记录所有 curl 消息(相当于curl -v),
  • GIT_TRACE_SHALLOW用于调试浅存储库的获取/克隆。

Possible values can include:

可能的值可以包括:

  • true, 1or 2to write to stderr,
  • an absolute path starting with /to trace output to the specified file.
  • true12写入标准错误,
  • /以跟踪输出到指定文件的绝对路径。

For more details, see: Git Internals - Environment Variables

有关更多详细信息,请参阅:Git Internals - 环境变量



SSH

SSH

For SSH issues, try the following commands:

对于 SSH 问题,请尝试以下命令:

echo 'ssh -vvv "$*"' > ssh && chmod +x ssh
GIT_SSH="$PWD/ssh" git pull origin master

or use sshto validate your credentials, e.g.

或用于ssh验证您的凭据,例如

ssh -vvvT [email protected]

or over HTTPS port:

或通过 HTTPS 端口:

ssh -vvvT -p 443 [email protected]

Note: Reduce number of -vto reduce the verbosity level.

注意:减少数量-v以降低详细程度。



Examples

例子

$ GIT_TRACE=1 git status
20:11:39.565701 git.c:350               trace: built-in: git 'status'

$ GIT_TRACE_PERFORMANCE=$PWD/gc.log git gc
Counting objects: 143760, done.
...
$ head gc.log 
20:12:37.214410 trace.c:420             performance: 0.090286000 s: git command: 'git' 'pack-refs' '--all' '--prune'
20:12:37.378101 trace.c:420             performance: 0.156971000 s: git command: 'git' 'reflog' 'expire' '--all'
...

$ GIT_TRACE_PACKET=true git pull origin master
20:16:53.062183 pkt-line.c:80           packet:        fetch< 93eb028c6b2f8b1d694d1173a4ddf32b48e371ce HEAD
GIT_TRACE=1 git pull origin master
multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed symref=HEAD:refs/heads/master agent=git/2:2.6.5~update-ref-initial-update-1494-g76b680d ...

回答by C.C.

try this one:

试试这个:

# Debug level 1
GIT_SSH_COMMAND="ssh -v" git clone <repositoryurl>

# Debug level 2
GIT_SSH_COMMAND="ssh -vv" git clone <repositoryurl>

# Debug level 3
GIT_SSH_COMMAND="ssh -vvv" git clone <repositoryurl>

回答by Basil Musa

If its over SSH, you can use the following:

如果通过 SSH,您可以使用以下命令:

For a higher debug level for type -vv or -vvv for debug level 2 and 3 respectively:

对于分别用于调试级别 2 和 3 的类型 -vv 或 -vvv 的更高调试级别:

GIT_TRACE_CURL

This is mainly useful to handle public and private key problems with the server. You can use this command for any git command, not only 'git clone'.

这主要用于处理服务器的公钥和私钥问题。您可以将此命令用于任何 git 命令,而不仅仅是“git clone”。

回答by VonC

Git 2.9.x/2.10 (Q3 2016) adds another debug option: GIT_TRACE_CURL.

Git 2.9.x/2.10(2016 年第三季度)添加了另一个调试选项:GIT_TRACE_CURL.

See commit 73e57aa, commit 74c682d(23 May 2016) by Elia Pinto (devzero2000).
Helped-by: Torsten B?gershausen (tboegi), Ramsay Jones , Junio C Hamano (gitster), Eric Sunshine (sunshineco), and Jeff King (peff).
(Merged by Junio C Hamano -- gitster--in commit 2f84df2, 06 Jul 2016)

请参阅Elia Pinto ( ) 的commit 73e57aacommit 74c682d(2016 年 5 月 23 日。 帮助者:Torsten B?gershausen ( )、Ramsay Jones、Junio C Hamano ( )Eric Sunshine ( )Jeff King ( )(由Junio C Hamano合并-- --2f84df2 提交中,2016 年 7 月 6 日)devzero2000
tboegigitstersunshinecopeff
gitster

http.c: implement the GIT_TRACE_CURLenvironment variable

Implement the GIT_TRACE_CURLenvironment variable to allow a greater degree of detail of GIT_CURL_VERBOSE, in particular the complete transport header and all the data payload exchanged.
It might be useful if a particular situation could require a more thorough debugging analysis.

http.c: 实现GIT_TRACE_CURL环境变量

实现GIT_TRACE_CURL环境变量以允许更大程度的细节GIT_CURL_VERBOSE,特别是完整的传输标头和所有交换的数据有效负载。
如果特定情况需要更彻底的调试分析,它可能会很有用。

The documentationwill state:

该文件将说明:

GIT_TRACE_CURL=true git clone --quiet $HTTPD_URL/smart/repo.git

Enables a curl full trace dump of all incoming and outgoing data, including descriptive information, of the git transport protocol.
This is similar to doing curl --trace-asciion the command line.

This option overrides setting the GIT_CURL_VERBOSEenvironment variable.

启用 git 传输协议的所有传入和传出数据(包括描述性信息)的 curl 完整跟踪转储。
这类似于curl --trace-ascii在命令行上执行的操作。

此选项会覆盖设置GIT_CURL_VERBOSE环境变量。



You can see that new option used in this answer, but also in the Git 2.11 (Q4 2016) tests:

您可以看到此答案中使用的新选项,但也可以在 Git 2.11(2016 年第 4 季度)测试中看到:

See commit 14e2411, commit 81590bf, commit 4527aa1, commit 4eee6c6(07 Sep 2016) by Elia Pinto (devzero2000).
(Merged by Junio C Hamano -- gitster--in commit 930b67e, 12 Sep 2016)

请参阅Elia Pinto ( ) 的commit 14e2411commit 81590bfcommit 4527aa1commit 4eee6c6(2016 年 9 月 7 日(由Junio C Hamano合并-- --提交 930b67e 中,2016 年 9 月 12 日)devzero2000
gitster

Use the new GIT_TRACE_CURLenvironment variable instead of the deprecatedGIT_CURL_VERBOSE.

使用新的GIT_TRACE_CURL环境变量而不是已弃用的GIT_CURL_VERBOSE.

$ git config --global trace2.normalTarget ~/log.normal
$ git version
git version 2.20.1.155.g426c96fcdb

回答by VonC

Git 2.22 (Q2 2019) introduces trace2with commit ee4512eby Jeff Hostetler:

Git的2.22(Q2 2019)介绍trace2承诺ee4512e杰夫·霍斯泰特勒

trace2: create new combined trace facility

Create a new unified tracing facility for git.
The eventual intent is to replace the current trace_printf*and trace_performance*routines with a unified set of git_trace2*routines.

In addition to the usual printf-style API, trace2provides higer-level event verbs with fixed-fields allowing structured data to be written.
This makes post-processing and analysis easier for external tools.

Trace2 defines 3 output targets.
These are set using the environment variables "GIT_TR2", "GIT_TR2_PERF", and "GIT_TR2_EVENT".
These may be set to "1" or to an absolute pathname (just like the current GIT_TRACE).

trace2: 创建新的组合跟踪工具

为 git 创建一个新的统一跟踪工具。
最终的意图是用一组统一的例程替换当前trace_printf*和例程。trace_performance*git_trace2*

除了通常的 printf 样式的 API 之外,trace2还提供具有固定字段的更高级别的事件动词,允许写入结构化数据。
这使得外部工具的后处理和分析更容易。

Trace2 定义了 3 个输出目标。
这些是使用环境变量“ GIT_TR2”、“ GIT_TR2_PERF”和“ GIT_TR2_EVENT”设置的。
这些可以设置为“1”或绝对路径名(就像当前的GIT_TRACE)。

Note: regarding environment variable name, always use GIT_TRACExxx, not GIT_TRxxx.
So actually GIT_TRACE2, GIT_TRACE2_PERFor GIT_TRACE2_EVENT.
See the Git 2.22 rename mentioned later below.

注意:关于环境变量名称,始终使用GIT_TRACExxx,而不是GIT_TRxxx
所以其实GIT_TRACE2GIT_TRACE2_PERF或者GIT_TRACE2_EVENT
请参阅下面提到的 Git 2.22 重命名。

What follows is the initialwork on this new tracing feature, with the oldenvironment variable names:

下面是这个新跟踪功能的初步工作,使用旧的环境变量名称:

  • GIT_TR2is intended to be a replacement for GIT_TRACEand logs command summary data.

  • GIT_TR2_PERFis intended as a replacement for GIT_TRACE_PERFORMANCE.
    It extends the output with columns for the command process, thread, repo, absolute and relative elapsed times. It reports events for child process start/stop, thread start/stop, and per-thread function nesting.

  • GIT_TR2_EVENTis a new structured format. It writes event data as a series of JSON records.

Calls to trace2 functions log to any of the 3 output targets enabled without the need to call different trace_printf*or trace_performance*routines.

  • GIT_TR2旨在替代GIT_TRACE和记录命令摘要数据。

  • GIT_TR2_PERF旨在替代GIT_TRACE_PERFORMANCE.
    它使用命令进程、线程、repo、绝对和相对经过时间的列扩展输出。它报告子进程启动/停止、线程启动/停止和每线程函数嵌套的事件。

  • GIT_TR2_EVENT是一种新的结构化格式。它将事件数据作为一系列 JSON 记录写入。

对 trace2 函数的调用记录到启用的 3 个输出目标中的任何一个,而无需调用不同的trace_printf*trace_performance*例程。

See commit a4d3a28(21 Mar 2019) by Josh Steadmon (steadmon).
(Merged by Junio C Hamano -- gitster--in commit 1b40314, 08 May 2019)

请参阅Josh Steadmon ( )提交的 a4d3a28(2019 年 3 月 21 日(由Junio C Hamano合并-- --commit 1b40314,2019 年 5 月 8 日)steadmon
gitster

trace2: write to directory targets

When the value of a trace2 environment variable is an absolute path referring to an existing directory, write output to files (one per process) underneath the given directory.
Files will be named according to the final component of the trace2 SID, followed by a counter to avoid potential collisions.

This makes it more convenient to collect traces for every git invocation by unconditionally setting the relevant trace2envvar to a constant directory name.

trace2: 写入目录目标

当 trace2 环境变量的值是引用现有目录的绝对路径时,将输出写入给定目录下的文件(每个进程一个)。
文件将根据 trace2 SID 的最终组成部分命名,后跟一个计数器以避免潜在的冲突。

通过无条件地将相关的trace2envvar设置为一个常量目录名称,这使得为​​每个 git 调用收集跟踪变得更加方便。



See also commit f672dee(29 Apr 2019), and commit 81567ca, commit 08881b9, commit bad229a, commit 26c6f25, commit bce9db6, commit 800a7f9, commit a7bc01e, commit 39f4317, commit a089724, commit 1703751(15 Apr 2019) by Jeff Hostetler (jeffhostetler).
(Merged by Junio C Hamano -- gitster--in commit 5b2d1c0, 13 May 2019)

参见提交f672dee(2019年4月29日),以及提交81567ca提交08881b9提交bad229a提交26c6f25提交bce9db6提交800a7f9提交a7bc01e提交39f4317提交a089724提交1703751(2019年4月15日)由杰夫霍斯泰特勒(jeffhostetler.
(由Junio C gitsterHamano合并-- --提交 5b2d1c0 中,2019 年 5 月 13 日)

The new documentationnow includes config settings which are only read from the system and global config files(meaning repository local and worktree config files and -ccommand line arguments are not respected.)

新文档现在包括它只能从系统和全局配置文件中读取配置设置(意库本地和worktree配置文件和-c命令行参数不被尊重。)

Example:

示例

$ cat ~/log.normal
12:28:42.620009 common-main.c:38                  version 2.20.1.155.g426c96fcdb
12:28:42.620989 common-main.c:39                  start git version
12:28:42.621101 git.c:432                         cmd_name version (version)
12:28:42.621215 git.c:662                         exit elapsed:0.001227 code:0
12:28:42.621250 trace2/tr2_tgt_normal.c:124 atexit elapsed:0.001265 code:0

yields

产量

$ git config --global trace2.perfTarget ~/log.perf
$ git version
git version 2.20.1.155.g426c96fcdb

And for performance measure:

对于绩效衡量

$ cat ~/log.perf
12:28:42.620675 common-main.c:38                  | d0 | main                     | version      |     |           |           |            | 2.20.1.155.g426c96fcdb
12:28:42.621001 common-main.c:39                  | d0 | main                     | start        |     |  0.001173 |           |            | git version
12:28:42.621111 git.c:432                         | d0 | main                     | cmd_name     |     |           |           |            | version (version)
12:28:42.621225 git.c:662                         | d0 | main                     | exit         |     |  0.001227 |           |            | code:0
12:28:42.621259 trace2/tr2_tgt_perf.c:211         | d0 | main                     | atexit       |     |  0.001265 |           |            | code:0

yields

产量

$ echo '/usr/bin/ssh -v ${@}' >/tmp/ssh
$ chmod +x /tmp/ssh
$ PATH=/tmp:${PATH} git clone ...
$ rm -f /tmp/ssh


As documented in Git 2.23 (Q3 2019), the environment variable to use is GIT_TRACE2.

如 Git 2.23(2019 年第三季度)中所述,要使用的环境变量是GIT_TRACE2.

See commit 6114a40(26 Jun 2019) by Carlo Marcelo Arenas Belón (carenas).
See commit 3efa1c6(12 Jun 2019) by ?var Arnfj?re Bjarmason (avar).
(Merged by Junio C Hamano -- gitster--in commit e9eaaa4, 09 Jul 2019)

请参阅Carlo Marcelo Arenas Belón ( ) 的commit 6114a40(2019 年 6 月 26 日。 请参阅?var Arnfj?re Bjarmason ( ) 的提交 3efa1c6(2019 年 6 月 12 日(由Junio C Hamano合并-- --提交 e9eaaa4,2019 年 7 月 9 日)carenas
avar
gitster

That follows the work done in Git 2.22: commit 4e0d3aa, commit e4b75d6(19 May 2019) by SZEDER Gábor (szeder).
(Merged by Junio C Hamano -- gitster--in commit 463dca6, 30 May 2019)

这是在 Git 2.22 中完成的工作:提交 4e0d3aa提交 e4b75d6(2019 年 5 月 19 日)由SZEDER Gábor ( szeder)
(由Junio C gitsterHamano合并-- --提交 463dca6 中,2019 年 5 月 30 日)

trace2: rename environment variables to GIT_TRACE2*

For an environment variable that is supposed to be set by users, the GIT_TR2*env vars are just too unclear, inconsistent, and ugly.

Most of the established GIT_*environment variables don't use abbreviations, and in case of the few that do (GIT_DIR, GIT_COMMON_DIR, GIT_DIFF_OPTS) it's quite obvious what the abbreviations (DIRand OPTS) stand for.
But what does TRstand for? Track, traditional, trailer, transaction, transfer, transformation, transition, translation, transplant, transport, traversal, tree, trigger, truncate, trust, or ...?!

The trace2 facility, as the '2' suffix in its name suggests, is supposed to eventually supercede Git's original trace facility.
It's reasonable to expect that the corresponding environment variables follow suit, and after the original GIT_TRACEvariables they are called GIT_TRACE2; there is no such thing is 'GIT_TR'.

All trace2-specific config variables are, very sensibly, in the 'trace2' section, not in 'tr2'.

OTOH, we don't gain anything at all by omitting the last three characters of "trace" from the names of these environment variables.

So let's rename all GIT_TR2*environment variables to GIT_TRACE2*, before they make their way into a stable release.

trace2: 将环境变量重命名为 GIT_TRACE2*

对于应该由用户设置的环境变量,环境变量GIT_TR2*太不清楚、不一致和丑陋。

大多数已建立的GIT_*环境变量不使用缩写,并且在少数使用 ( GIT_DIR, GIT_COMMON_DIR, GIT_DIFF_OPTS) 的情况下,缩写 (DIROPTS) 代表的含义非常明显。
但代表什么TR?跟踪、传统、拖车、事务、转移、转换、过渡、翻译、移植、传输、遍历、树、触发器、截断、信任或......?!

trace2 工具,正如其名称中的“2”后缀所暗示的那样,应该最终取代 Git 的原始跟踪工具。
可以合理地期望相应的环境变量也随之而来,并在原始GIT_TRACE变量之后调用它们GIT_TRACE2;没有这样的东西是' GIT_TR'。

所有 trace2 特定的配置变量都非常明智地位于“ trace2”部分,而不是“ tr2”。

OTOH,通过从这些环境变量的名称中省略“trace”的最后三个字符我们根本没有任何好处

因此,让我们将所有GIT_TR2*环境变量重命名为GIT_TRACE2*, 在它们进入稳定版本之前。



Git 2.24 (Q3 2019) improves the Git repository initialization.

Git 2.24(2019 年第三季度)改进了 Git 存储库初始化。

See commit 22932d9, commit 5732f2b, commit 58ebccb(06 Aug 2019) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster--in commit b4a1eec, 09 Sep 2019)

请参阅Jeff King ( ) 的commit 22932d9commit 5732f2bcommit 58ebccb(2019 年 8 月 6 日(由Junio C Hamano合并-- --提交 b4a1eec,2019 年 9 月 9 日)peff
gitster

common-main: delay trace2 initialization

We initialize the trace2system in the common main() function so that all programs (even ones that aren't builtins) will enable tracing.

But trace2startup is relatively heavy-weight, as we have to actually read on-disk config to decide whether to trace.
This can cause unexpected interactions with other common-main initialization. For instance, we'll end up in the config code before calling initialize_the_repository(), and the usual invariant that the_repositoryis never NULL will not hold.

Let's push the trace2initialization further down in common-main, to just before we execute cmd_main().

common-main: 延迟 trace2 初始化

我们trace2在通用的 main() 函数中初始化系统,以便所有程序(即使不是内置程序)都可以启用跟踪。

但是trace2启动是相对重量级的,因为我们必须实际读取磁盘配置来决定是否进行跟踪。
这可能会导致与其他 common-main 初始化的意外交互。例如,在调用之前,我们将在配置代码中结束initialize_the_repository(),并且通常的不the_repository为 NULL 的不变量将不成立。

让我们将trace2common-main 中的初始化进一步推到我们执行之前cmd_main()



Git 2.24 (Q4 2019) makes also sure that output from trace2subsystem is formatted more prettily now.

Git 2.24(2019 年第四季度)还确保trace2现在子系统的输出格式更漂亮。

See commit 742ed63, commit e344305, commit c2b890a(09 Aug 2019), commit ad43e37, commit 04f10d3, commit da4589c(08 Aug 2019), and commit 371df1b(31 Jul 2019) by Jeff Hostetler (jeffhostetler).
(Merged by Junio C Hamano -- gitster--in commit 93fc876, 30 Sep 2019)

提交742ed63提交e344305提交c2b890a(2019年8月9日),提交ad43e37提交04f10d3提交da4589c(2019年8月8日),并提交371df1b(2019年7月31日),由杰夫·霍斯泰特勒(jeffhostetler
(由Junio C gitsterHamano合并-- --提交 93fc876 中,2019 年 9 月 30 日)

And, still Git 2.24

而且,仍然是 Git 2.24

See commit 87db61a, commit 83e57b0(04 Oct 2019), and commit 2254101, commit 3d4548e(03 Oct 2019) by Josh Steadmon (steadmon).
(Merged by Junio C Hamano -- gitster--in commit d0ce4d9, 15 Oct 2019)

请参阅Josh Steadmon ( ) 的commit 87db61acommit 83e57b0(2019 年 10 月 4 日)和commit 2254101commit 3d4548e(2019 年 10 月 3 日(由Junio C Hamano合并-- --d0ce4d9 提交中,2019 年 10 月 15 日)steadmon
gitster

trace2: discard new traces if target directory has too many files

Signed-off-by: Josh Steadmon

trace2can write files into a target directory.
With heavy usage, this directory can fill up with files, causing difficulty for trace-processing systems.

This patch adds a config option (trace2.maxFiles) to set a maximum number of files that trace2will write to a target directory.

The following behavior is enabled when the maxFilesis set to a positive integer:

  • When trace2would write a file to a target directory, first check whether or not the traces should be discarded. Traces should be discarded if:

    • there is a sentinel file declaring that there are too many files
    • OR, the number of files exceeds trace2.maxFiles.
      In the latter case, we create a sentinel file named git-trace2-discardto speed up future checks.

The assumption is that a separate trace-processing system is dealing with the generated traces; once it processes and removes the sentinel file, it should be safe to generate new trace files again.

The default value for trace2.maxFilesis zero, which disables the file count check.

The config can also be overridden with a new environment variable: GIT_TRACE2_MAX_FILES.

trace2: 如果目标目录有太多文件,则丢弃新的痕迹

签字人:Josh Steadmon

trace2可以将文件写入目标目录。
大量使用时,此目录可能会填满文件,从而给跟踪处理系统带来困难。

此补丁添加了一个配置选项 ( trace2.maxFiles) 来设置trace2将写入目标目录的最大文件数。

maxFiles设置为正整数时,将启用以下行为:

  • 何时trace2将文件写入目标目录,首先检查是否应丢弃跟踪。如果出现以下情况,应丢弃痕迹:

    • 有一个哨兵文件声明文件太多
    • 或者,文件数量超过trace2.maxFiles.
      在后一种情况下,我们创建一个名为的哨兵文件以git-trace2-discard加快未来的检查。

假设是一个单独的跟踪处理系统正在处理生成的跟踪;一旦它处理并删除了哨兵文件,再次生成新的跟踪文件应该是安全的。

的默认值trace2.maxFiles为零,这将禁用文件计数检查。

也可以使用新的环境变量覆盖配置:GIT_TRACE2_MAX_FILES.



And Git 2.24 (Q4 2019) teach trace2 about git pushstages.

Git 2.24(2019 年第 4 季度)教 trace2 关于git push阶段。

See commit 25e4b80, commit 5fc3118(02 Oct 2019) by Josh Steadmon (steadmon).
(Merged by Junio C Hamano -- gitster--in commit 3b9ec27, 15 Oct 2019)

请参阅Josh Steadmon ( ) 的commit 25e4b80commit 5fc3118(2019 年 10 月 2 日(由Junio C Hamano合并-- --3b9ec27 提交中,2019 年 10 月 15 日)steadmon
gitster

push: add trace2 instrumentation

Signed-off-by: Josh Steadmon

Add trace2 regions in transport.cand builtin/push.cto better track time spent in various phases of pushing:

  • Listing refs
  • Checking submodules
  • Pushing submodules
  • Pushing refs

push: 添加 trace2 检测

签字人:Josh Steadmon

添加 trace2 区域transport.cbuiltin/push.c更好地跟踪在推送的各个阶段花费的时间:

  • 列表参考
  • 检查子模块
  • 推送子模块
  • 推送参考


With Git 2.25 (Q1 2020), some of the Documentation/technicalis moved to header *.hfiles.

在 Git 2.25(2020 年第一季度)中,其中一些Documentation/technical被移到头*.h文件中。

See commit 6c51cb5, commit d95a77d, commit bbcfa30, commit f1ecbe0, commit 4c4066d, commit 7db0305, commit f3b9055, commit 971b1f2, commit 13aa9c8, commit c0be43f, commit 19ef3dd, commit 301d595, commit 3a1b341, commit 126c1cc, commit d27eb35, commit 405c6b1, commit d3d7172, commit 3f1480b, commit 266f03e, commit 13c4d7e(17 Nov 2019) by Heba Waly (HebaWaly).
(Merged by Junio C Hamano -- gitster--in commit 26c816a, 16 Dec 2019)

提交6c51cb5提交d95a77d提交bbcfa30提交f1ecbe0提交4c4066d提交7db0305提交f3b9055提交971b1f2提交13aa9c8提交c0be43f提交19ef3dd提交301d595提交3a1b341提交126c1cc提交d27eb35提交405c6b1提交d3d7172提交 3f1480b提交 266f03e提交 13c4d7e(2019 年 11 月 17 日)由Heba Waly ( HebaWaly)
(由Junio C gitsterHamano合并-- --commit 26c816a,2019 年 12 月 16 日)

trace2: move doc to trace2.h

Signed-off-by: Heba Waly

Move the functions documentation from Documentation/technical/api-trace2.txtto trace2.has it's easier for the developers to find the usage information beside the code instead of looking for it in another doc file.

Only the functions documentation section is removed from Documentation/technical/api-trace2.txtas the file is full of details that seemed more appropriate to be in a separate doc file as it is, with a link to the doc file added in the trace2.h. Also the functions doc is removed to avoid having redundandt info which will be hard to keep syncronized with the documentation in the header file.

trace2: 将文档移至 trace2.h

签字人:Heba Waly

将函数文档从Documentation/technical/api-trace2.txt移到 ,trace2.h因为开发人员可以更轻松地找到代码旁边的使用信息,而不是在另一个 doc 文件中查找。

只删除了函数文档部分,Documentation/technical/api-trace2.txt因为该文件充满了细节,看起来更适合放在单独的 doc 文件中,并在 trace2.h 中添加了指向 doc 文件的链接。此外,函数 doc 被删除以避免冗余信息,这将难以与头文件中的文档保持同步。

(although that reorganization had a side effect on another command, explained and fixed with Git 2.25.2 (March 2020) in commit cc4f2eb(14 Feb 2020) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster--in commit 1235384, 17 Feb 2020))

(尽管该重组对另一个命令产生了副作用,在Jeff King ( )提交的 cc4f2eb(14 Feb 2020)中用 Git 2.25.2(2020 年 3 月)进行了解释和修复。(由Junio C Hamano合并-- --提交中) 1235384,2020年 2 月 17 日))peff
gitster



With Git 2.27 (Q2 2020): Trace2 enhancement to allow logging of the environment variables.

使用 Git 2.27(2020 年第二季度):Trace2 增强以允许记录环境变量

See commit 3d3adaa(20 Mar 2020) by Josh Steadmon (steadmon).
(Merged by Junio C Hamano -- gitster--in commit 810dc64, 22 Apr 2020)

请参阅Josh Steadmon ( ) 的commit 3d3adaa(20 Mar 2020 )(由Junio C Hamano合并-- --提交 810dc64 中,2020 年 4 月 22 日)steadmon
gitster

trace2: teach Git to log environment variables

Signed-off-by: Josh Steadmon
Acked-by: Jeff Hostetler

Via trace2, Git can already log interesting config parameters (see the trace2_cmd_list_config()function). However, this can grant an incomplete picture because many config parameters also allow overrides via environment variables.

To allow for more complete logs, we add a new trace2_cmd_list_env_vars()function and supporting implementation, modeled after the pre-existing config param logging implementation.

trace2: 教 Git 记录环境变量

签字人:Josh Steadmon
认可人:Jeff Hostetler

通过 trace2,Git 已经可以记录有趣的配置参数(见trace2_cmd_list_config()函数)。但是,这可能会导致图像不完整,因为许多配置参数也允许通过环境变量进行覆盖。

为了允许更完整的日志,我们添加了一个新trace2_cmd_list_env_vars()功能和支持实现,以预先存在的配置参数日志记录实现为模型。



With Git 2.27 (Q2 2020), teach codepaths that show progress meter to also use the start_progress()and the stop_progress()calls as a "region" to be traced.

使用 Git 2.27(2020 年第二季度),教显示进度表的代码路径也使用start_progress()stop_progress()调用作为region要跟踪的“ ”。

See commit 98a1364(12 May 2020) by Emily Shaffer (nasamuffin).
(Merged by Junio C Hamano -- gitster--in commit d98abce, 14 May 2020)

请参阅Emily Shaffer ( ) 的提交 98a1364(2020 年 5 月 12 日(由Junio C Hamano合并-- --d98abce 提交中,2020 年 5 月 14 日)nasamuffin
gitster

trace2: log progress time and throughput

Signed-off-by: Emily Shaffer

Rather than teaching only one operation, like 'git fetch', how to write down throughput to traces, we can learn about a wide range of user operations that may seem slow by adding tooling to the progress library itself.

Operations which display progress are likely to be slow-running and the kind of thing we want to monitor for performance anyways.

By showing object counts and data transfer size, we should be able to make some derived measurements to ensure operations are scaling the way we expect.

trace2:记录进度时间和吞吐量

签字人:Emily Shaffer

我们可以通过向进度库本身添加工具来了解各种可能看起来很慢的用户操作,而不是只教授一种操作,例如“ git fetch”,如何将吞吐量记录到跟踪中。

显示进度的操作可能运行缓慢,并且无论如何我们都希望监控性能。

通过显示对象计数和数据传输大小,我们应该能够进行一些派生的测量,以确保操作按我们期望的方式扩展。

And:

和:

With Git 2.27 (Q2 2020), last-minute fix for our recent change to allow use of progress API as a traceable region.

Git 2.27(2020 年第二季度)是我们最近更改的最后一刻修复,允许使用进度 API 作为可跟踪区域。

See commit 3af029c(15 May 2020) by Derrick Stolee (derrickstolee).
(Merged by Junio C Hamano -- gitster--in commit 85d6e28, 20 May 2020)

请参阅Derrick Stolee ( ) 的commit 3af029c(2020 年 5 月 15 日(由Junio C Hamano合并-- --提交 85d6e28 中,2020 年 5 月 20 日)derrickstolee
gitster

progress: call trace2_region_leave()only after calling _enter()

Signed-off-by: Derrick Stolee

A user of progress API calls start_progress()conditionally and depends on the display_progress()and stop_progress()functions to become no-op when start_progress()hasn't been called.

As we added a call to trace2_region_enter()to start_progress(), the calls to other trace2 API calls from the progress API functions must make sure that these trace2 calls are skipped when start_progress()hasn't been called on the progress struct.

Specifically, do not call trace2_region_leave()from stop_progress()when we haven't called start_progress(), which would have called the matching trace2_region_enter().

progress:trace2_region_leave()只在调用后调用_enter()

签字人:德里克·斯托利

进度 API 的用户start_progress()有条件地调用并依赖display_progress()stop_progress()函数在start_progress()未被调用时变为空操作。

由于我们增加了一个调用trace2_region_enter()start_progress(),从进度API函数等TRACE2 API调用的调用必须确保这些TRACE2电话是跳过时start_progress()没有被调用的进展结构。

具体地讲,不叫trace2_region_leave()stop_progress()时候,我们不叫start_progress(),这会叫的匹配trace2_region_enter()

回答by JamesHalsall

Have you tried adding the verbose (-v) operator when you clone?

您是否尝试-v在克隆时添加详细 ( ) 运算符?

git clone -v git://git.kernel.org/pub/scm/.../linux-2.6 my2.6

git clone -v git://git.kernel.org/pub/scm/.../linux-2.6 my2.6

回答by qneill

For older git versions (1.8 and before)

对于较旧的 git 版本(1.8 及之前)

I could find no suitable way to enable SSH debuggingin an older git and ssh versions. I looked for environment variables using ltrace -e getenv ...and couldn't find any combination of GIT_TRACE or SSH_DEBUG variables that would work.

我找不到合适的方法在较旧的 git 和 ssh 版本中启用 SSH 调试。我查找了使用的环境变量ltrace -e getenv ...,但找不到任何可行的 GIT_TRACE 或 SSH_DEBUG 变量组合。

Instead here's a recipe to temporarily inject 'ssh -v' into the git->ssh sequence:

相反,这里有一个将 'ssh -v' 临时注入 git->ssh 序列的方法:

$ (echo '/usr/bin/ssh -v ${@}' >/tmp/ssh; chmod +x /tmp/ssh; PATH=/tmp:${PATH} \
   GIT_TRACE=1 git clone https://github.com/qneill/cliff.git; \
   rm -f /tmp/ssh) 2>&1 | tee log
trace: built-in: git 'clone' 'https://github.com/qneill/cliff.git'
trace: run_command: 'git-remote-https' 'origin' 'https://github.com/qneill/cliff.git'
Cloning into 'cliff'...
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /home/q.neill/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to github.com ...
...
Transferred: sent 4120, received 724232 bytes, in 0.2 seconds
Bytes per second: sent 21590.6, received 3795287.2
debug1: Exit status 0
trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all'
trace: exec: 'git' 'rev-list' '--objects' '--stdin' '--not' '--all'
trace: built-in: git 'rev-list' '--objects' '--stdin' '--not' '--all'

Here's output from git version 1.8.3with ssh version OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013cloning a github repo:

以下是1.8.3git和 ssh 版OpenSSH_5.3p1、OpenSSL 1.0.1e-fips 2013 年 2 月 11 日克隆 github 存储库的输出:

##代码##