git/list[1] front-page[2] threads[3] people[4] search[5] about
 

BUG: git verify-pack --stat-only is nonfunctional as documented

From
Ccalumlikesapplepie@gmail.com <calumlikesapplepie@gmail.com>
Date
Dec 8, 2024, 20:39 UTC
Message-ID
<1ee9f3ef2bffd148b6225138135462d2d4a5928d.camel@gmail.com>
Hello maintainers,

There are two problems with `git verify-pack --stat-only`. The first one I noticed is that it does not work as specified when the --verbose option is passed. The second, and more serious, is that it simply doesn't work in general; `verify-pack` runs at the same speed regardlesds of if `--stat-only` is specified.

The manpage of `git verify-pack` specifies that when both the  `--verbose` and `--stat-only` options are passed, that the command outputs both a complete list of objects and a histogram.

> -s, --stat-only
>       Do not verify the pack contents; only show the histogram 
> 	of delta chain length. With --verbose, the list of objects
>	is also shown.

However, running `git verify-pack -sv` only outputs the histogram. Examining the source code reveals that this is the expected behavior in all cases; if --stat-only is specified, --verbose is ignored.

Show 9 quoted lines
> static int verify_one_pack(... ) { ...
> 	strvec_push(argv, "index-pack");
>
> 	if (stat_only)
> 		strvec_push(argv, "--verify-stat-only");
> 	else if (verbose)
> 		strvec_push(argv, "--verify-stat");
> 	else
> 		strvec_push(argv, "--verify");

While trying to determine how to patch this function and `index-pack.c` to support the manpage specified behavior, I realized that I couldn't even locate where --verify-stat-only prevented the hashing of the full pack file; the `stat_only` variable only serves to prevent printing of individual object information. Timing data confirms that `--stat-only` does not prevent verifying the packfiles; the following test case shows either command taking about a second to run on my machine.

Show 5 quoted lines
> dd if=/dev/urandom of=test123.rand count=10 bs=10M
> git init; git add .; git commit -am "test"
> git gc
> time git verify-pack .git/objects/pack/PACKFILE.idx
> time git verify-pack --stat-only .git/objects/pack/PACKFILE.idx

Both issues were likley added when `verify-pack` was refactored to call `index-pack`. It may be simpler to edit the manpage to reflect the current behavior, rather than conduct the needed refactoring of `index- pack`. A patch that does this is incoming..

Thank you, Calum McConnell

P.S. Sorry if this message seemed rude or too short, it's the second time I've written it, since Evolution decided to discard my message text.

Next: Calum McConnell
Message 1 of 4 in “BUG: git verify-pack --stat-only is nonfunctional as documented”
  1. calumlikesapplepie@gmail.comDec 8, 2024
  2. verify-pack: Fix documentation of --stat-only to reflect behaviorCalum McConnell, Dec 8, 2024
  3. Junio C HamanoDec 9, 2024
  4. A bughunterDec 11, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.