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

[PATCH] verify-pack: Fix documentation of --stat-only to reflect behavior

From
CMCalum McConnell <calumlikesapplepie@gmail.com>
Date
Dec 8, 2024, 20:47 UTC
Message-ID
<20241208204733.304109-2-calumlikesapplepie@gmail.com>
In-Reply-To
<1ee9f3ef2bffd148b6225138135462d2d4a5928d.camel@gmail.com>

Ever since verify-pack was refactored to use `index-pack.c` in commit 3de89c9 (verify-pack: use index-pack --verify, 2011-06-06), the --stat-only option has been verifying the full pack, rather than just reading the index file, as it was originally documented to do.

Allowing users to get details of packed objects rapidly without needing to hash all the objects in packfile is a useful ability. Interested consumers could use such data to more rapidly estimate the effectiveness of git's compression, such as to determine if their .gitignore is adequate, or if they should be removing additional files. However, implementing that ability would require more changes to index-pack than the author is able to do at this time, and so a quick fix to simply update the documentation to reflect current behavior is done instead.

This commit also re-orders the if-else block, to ensure that if both --stat-only and --verbose are specified, the verbose details are provided. This fixes another longstanding documentation bug with `verify-pack`.

Signed-off-by: Calum McConnell <calumlikesapplepie@gmail.com>
---
 Documentation/git-verify-pack.txt | 4 ++--
 builtin/verify-pack.c             | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-verify-pack.txt b/Documentation/git-verify-pack.txt
index d7e8869..f734e90 100644
--- a/Documentation/git-verify-pack.txt
+++ b/Documentation/git-verify-pack.txt
@@ -30,8 +30,8 @@ OPTIONS
 
 -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.
+	As --verbose, but only show the histogram of delta
+	chain length.
 
 \--::
 	Do not interpret any more arguments as options.
diff --git a/builtin/verify-pack.c b/builtin/verify-pack.c
index 34e4ed7..5860a96 100644
--- a/builtin/verify-pack.c
+++ b/builtin/verify-pack.c
@@ -20,10 +20,10 @@ static int verify_one_pack(const char *path, unsigned int flags, const char *has
 
 	strvec_push(argv, "index-pack");
 
-	if (stat_only)
-		strvec_push(argv, "--verify-stat-only");
-	else if (verbose)
+	if (verbose)
 		strvec_push(argv, "--verify-stat");
+	else if (stat_only)
+		strvec_push(argv, "--verify-stat-only");
 	else
 		strvec_push(argv, "--verify");
 
-- 
2.45.2
Previous: calumlikesapplepie@gmail.comNext: Junio C Hamano
Message 2 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.