我怎么能有一些关于git/git-shell的调试信息?

我遇到了一个问题,user1可以毫无问题地克隆一个存储库,而user2只能克隆一个空的存储库。我设置了GIT_TRACE=1,但是没有任何有用的提示。

最后,经过长时间的尝试和错误,发现这是一个文件的权限问题。适当的错误消息可以避免此问题。


当前回答

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

Git克隆-v Git://git.kernel.org/pub/scm/.../linux-2.6 my2.6

其他回答

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

Git克隆-v Git://git.kernel.org/pub/scm/.../linux-2.6 my2.6

Git 2.39 (Q4 2022)增加了两个新的跟踪功能,“计时器”和“计数器”:

参见Jeff Hostetler (Jeff-Hostetler)的commit 8107162, commit 8ad5756, commit 24a4c45, commit 3124793, commit a70839c, commit 8e8c5ad, commit 5bbb925, commit 545ddca(2022年10月24日)。 (由Taylor Blau—Taylor—在commit e5be3c6中合并,2022年10月30日)

Trace2:添加秒表计时器 署名:Jeff Hostetler

Timers are an alternative to Trace2 Regions. Regions are useful for measuring the time spent in various computation phases, such as the time to read the index, time to scan for unstaged files, time to scan for untracked files, and etc. However, regions are not appropriate in all places. For example, during a checkout, it would be very inefficient to use regions to measure the total time spent inflating objects from the ODB (Object DataBase) from across the entire lifetime of the process; a per-unzip() region would flood the output and significantly slow the command; and some form of post-processing would be required to compute the time spent in unzip(). Timers can be used to measure a series of timer intervals and emit a single summary event (at thread and/or process exit).

Technical /api-trace2现在在它的手册页中包括:

"th_timer" This event logs the amount of time that a stopwatch timer was running in the thread. This event is generated when a thread exits for timers that requested per-thread events. { "event":"th_timer", ... "category":"my_category", "name":"my_timer", "intervals":5, # number of time it was started/stopped "t_total":0.052741, # total time in seconds it was running "t_min":0.010061, # shortest interval "t_max":0.011648 # longest interval } "timer" This event logs the amount of time that a stopwatch timer was running aggregated across all threads. This event is generated when the process exits. { "event":"timer", ... "category":"my_category", "name":"my_timer", "intervals":5, # number of time it was started/stopped "t_total":0.052741, # total time in seconds it was running "t_min":0.010061, # shortest interval "t_max":0.011648 # longest interval }

Technical /api-trace2现在在它的手册页中包括:

Stopwatch Timer Events Measure the time spent in a function call or span of code that might be called from many places within the code throughout the life of the process. static void expensive_function(void) { trace2_timer_start(TRACE2_TIMER_ID_TEST1); ... sleep_millisec(1000); // Do something expensive ... trace2_timer_stop(TRACE2_TIMER_ID_TEST1); } static int ut_100timer(int argc, const char **argv) { ... expensive_function(); // Do something else 1... expensive_function(); // Do something else 2... expensive_function(); return 0; } In this example, we measure the total time spent in expensive_function() regardless of when it is called in the overall flow of the program. $ export GIT_TRACE2_PERF_BRIEF=1 $ export GIT_TRACE2_PERF=~/log.perf $ t/helper/test-tool trace2 100timer 3 1000 ... $ cat ~/log.perf d0 | main | version | | | | | ... d0 | main | start | | 0.001453 | | | t/helper/test-tool trace2 100timer 3 1000 d0 | main | cmd_name | | | | | trace2 (trace2) d0 | main | exit | | 3.003667 | | | code:0 d0 | main | timer | | | | test | name:test1 intervals:3 total:3.001686 min:1.000254 max:1.000929 d0 | main | atexit | | 3.003796 | | | code:0

并且,仍然使用Git 2.39:

Trace2:添加全局计数器机制 署名:Jeff Hostetler

Add global counters mechanism to Trace2. The Trace2 counters mechanism adds the ability to create a set of global counter variables and an API to increment them efficiently. Counters can optionally report per-thread usage in addition to the sum across all threads. Counter events are emitted to the Trace2 logs when a thread exits and at process exit. Counters are an alternative to data and data_json events. Counters are useful when you want to measure something across the life of the process, when you don't want per-measurement events for performance reasons, when the data does not fit conveniently within a region, or when your control flow does not easily let you write the final total. For example, you might use this to report the number of calls to unzip() or the number of de-delta steps during a checkout.

Technical /api-trace2现在在它的手册页中包括:

"th_counter" This event logs the value of a counter variable in a thread. This event is generated when a thread exits for counters that requested per-thread events. { "event":"th_counter", ... "category":"my_category", "name":"my_counter", "count":23 } "counter" This event logs the value of a counter variable across all threads. This event is generated when the process exits. The total value reported here is the sum across all threads. { "event":"counter", ... "category":"my_category", "name":"my_counter", "count":23 }

Git 2.9.x/2.10(2016年Q3)增加了另一个调试选项:GIT_TRACE_CURL。

参见Elia Pinto (devzero2000)的commit 73e57aa, commit 74c682d(2016年5月23日)。 帮助:Torsten Bögershausen (tboegi), Ramsay Jones ramsay@ramsayjones.plus.com, Junio C Hamano (gitster), Eric Sunshine (sunshineco),和Jeff King (peff)。 (由Junio C Hamano—gitster—在提交2f84df2中合并,2016年7月6日)

c:实现GIT_TRACE_CURL环境变量

实现GIT_TRACE_CURL环境变量,以允许更详细地了解GIT_CURL_VERBOSE,特别是完整的传输报头和交换的所有数据有效负载。 如果某个特定的情况需要更彻底的调试分析,那么它可能会很有用。

该文件将说明:

GIT_TRACE_CURL 启用所有传入和传出数据的curl完整跟踪转储,包括git传输协议的描述性信息。 这类似于在命令行上执行curl——trace-ascii。 该选项将覆盖设置GIT_CURL_VERBOSE环境变量。


你可以在这个答案中看到这个新选项,在Git 2.11(2016年Q4)测试中也有使用:

参见Elia Pinto (devzero2000)的commit 14e2411, commit 81590bf, commit 4527aa1, commit 4eee6c6(2016年9月07日)。 (由Junio C Hamano—gitster—在commit 930b67e中合并,2016年9月12日)

请使用新的GIT_TRACE_CURL环境变量 已弃用的GIT_CURL_VERBOSE。

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

请注意,并非所有命令都必须发出跟踪。 例如:你需要Git 2.32 (Q2 2021)才能让reflog失效机制发出跟踪事件。

参见hanwen Nienhuys提交的34c3199(2021年4月23日)。 (由Junio C Hamano—gitster—在commit a850356中合并,2021年5月7日)

参考/调试:跟踪到reflog到期 签署人:Han-Wen Nienhuys


使用Git 2.39 (Q4 2022),在GIT_CURL_VERBOSE和其他文件中编校cURL的h2h3模块的头文件。

参见Glen Choo (chooglen)提交的b637a41(2022年11月11日)。 参见Jeff King (peff)提交73c49a4(2022年11月11日)。 (由Junio C Hamano—gitster—在commit 6adf170中合并,2022年11月23日)

Http:在info中编辑curl h2h3头文件 资助人:杰夫·金 署名:Glen Choo 署名:泰勒·布劳

With GIT_TRACE_CURL=1 or GIT_CURL_VERBOSE=1, sensitive headers like "Authorization" and "Cookie" get redacted. However, since curl/curl commit f8c3724, curl's h2h3 module (invoked when using HTTP/2) also prints headers in its "info", which don't get redacted. For example, echo 'github.com TRUE / FALSE 1698960413304 o foo=bar' >cookiefile && GIT_TRACE_CURL=1 GIT_TRACE_CURL_NO_DATA=1 git \ -c 'http.cookiefile=cookiefile' \ -c 'http.version=' \ ls-remote https://github.com/git/git refs/heads/main 2>output && grep 'cookie' output produces output like: 23:04:16.920495 http.c:678 == Info: h2h3 [cookie: o=foo=bar] 23:04:16.920562 http.c:637 => Send header: cookie: o=<redacted> Teach http.c to check for h2h3 headers in info and redact them using the existing header redaction logic. This fixes the broken redaction logic that we noted in the previous commit, so mark the redaction tests as passing under HTTP2.

试试这个:

GIT_TRACE=1 git pull origin master

在Git 2.37 (Q3 2022)中,引入了一个新的bug()和BUG_if_bug() API,以便更容易地统一记录“检测多个错误并最终中止”模式。

这将是trace2输出的一部分,用于调试git-shell相关的问题。

参见 Ævar Arnfjörð Bjarmason (avar) 的提交 6d40f0a、提交 07b1d8f、提交 5b2f5d9、提交 53ca569、提交 0cc05b0、提交 19d7594(2022 年 6 月 2 日)。 (由 Junio C Hamano -- gitster -- 合并于 提交 4da14b5,2022 年 6 月 10 日)

usage.c:添加一个非致命的bug()函数来配合bug() 署名:Ævar Arnfjörð Bjarmason

Add a bug() function to use in cases where we'd like to indicate a runtime BUG(), but would like to defer the BUG() call because we're possibly accumulating more bug() callers to exhaustively indicate what went wrong. We already have this sort of facility in various parts of the codebase, just in the form of ad-hoc re-inventions of the functionality that this new API provides. E.g. this will be used to replace optbug() in parse-options.c, and the 'error("BUG:[...]' we do in a loop in builtin/receive-pack.c. Unlike the code this replaces we'll log to trace2 with this new bug() function (as with other usage.c functions, including BUG()), we'll also be able to avoid calls to xstrfmt() in some cases, as the bug() function itself accepts variadic sprintf()-like arguments. Any caller to bug() can follow up such calls with BUG_if_bug(), which will BUG() out (i.e. abort()) if there were any preceding calls to bug(), callers can also decide not to call BUG_if_bug() and leave the resulting BUG() invocation until exit() time. There are currently no bug() API users that don't call BUG_if_bug() themselves after a for-loop, but allowing for not calling BUG_if_bug() keeps the API flexible. As the tests and documentation here show we'll catch missing BUG_if_bug() invocations in our exit() wrapper.

技术/api错误处理现在包括在它的手册页:

的BUG、BUG、死亡、使用、错误和警告报告错误

技术/api错误处理现在包括在它的手册页:

bug (lower-case, not BUG) is supposed to be used like BUG but prints a "BUG" message instead of calling abort(). A call to bug() will then result in a "real" call to the BUG() function, either explicitly by invoking BUG_if_bug() after call(s) to bug(), or implicitly at exit() time where we'll check if we encountered any outstanding bug() invocations. If there were no prior calls to bug() before invoking BUG_if_bug() the latter is a NOOP. The BUG_if_bug() function takes the same arguments as BUG() itself. Calling BUG_if_bug() explicitly isn't necessary, but ensures that we die as soon as possible. If you know you had prior calls to bug() then calling BUG() itself is equivalent to calling BUG_if_bug(), the latter being a wrapper calling BUG() if we've set a flag indicating that we've called bug().

Technical /api-trace2现在在它的手册页中包括:

当BUG()、BUG()、error()、 调用Die()、warning()或usage()函数。


使用Git 2.38 (Q3 2022),您甚至可以打印命令在运行时使用的配置值。