git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* BUG: git verify-pack --stat-only is nonfunctional as documented
@ 2024-12-08 20:39 calumlikesapplepie
  2024-12-08 20:47 ` [PATCH] verify-pack: Fix documentation of --stat-only to reflect behavior Calum McConnell
  2024-12-11  6:14 ` BUG: git verify-pack --stat-only is nonfunctional as documented A bughunter
  0 siblings, 2 replies; 4+ messages in thread
From: calumlikesapplepie @ 2024-12-08 20:39 UTC (permalink / raw)
  To: git

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.

> 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.

> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-11  6:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-08 20:39 BUG: git verify-pack --stat-only is nonfunctional as documented calumlikesapplepie
2024-12-08 20:47 ` [PATCH] verify-pack: Fix documentation of --stat-only to reflect behavior Calum McConnell
2024-12-09  0:51   ` Junio C Hamano
2024-12-11  6:14 ` BUG: git verify-pack --stat-only is nonfunctional as documented A bughunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).