From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, me@ttaylorr.com,
Derrick Stolee <derrickstolee@github.com>
Subject: [PATCH v2 0/2] fsck: verify .bitmap checksums, cleanup
Date: Tue, 02 May 2023 13:27:20 +0000 [thread overview]
Message-ID: <pull.1526.v2.git.1683034042.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1526.git.1682965295.gitgitgadget@gmail.com>
Similar to the recent work on rev-indexes [1], add checks for .bitmap files
to 'git fsck'.
Patch 1 includes the full details for .bitmap files.
Patch 2 includes a cleanup of ds/fsck-pack-revindex that I noticed while
preparing this series.
Updates since v2
================
* The code for verify_bitmap_file() added checks for a negative file
descriptor, as well as some other cleanup.
* The test in t5326 is expanded to include the "both are corrupt" case, as
well as a reorganization because the test was not confined to an inner
repo.
Thanks, Stolee
[1]
https://lore.kernel.org/git/pull.1512.git.1681748502.gitgitgadget@gmail.com/
Derrick Stolee (2):
fsck: verify checksums of all .bitmap files
fsck: use local repository
builtin/fsck.c | 10 +++++---
pack-bitmap.c | 45 +++++++++++++++++++++++++++++++++++
pack-bitmap.h | 2 ++
t/t5326-multi-pack-bitmaps.sh | 44 ++++++++++++++++++++++++++++++++++
4 files changed, 98 insertions(+), 3 deletions(-)
base-commit: 48d89b51b3bb8a60580c36731b96a7206ce1e5b9
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1526%2Fderrickstolee%2Ffsck-bitmap-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1526/derrickstolee/fsck-bitmap-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1526
Range-diff vs v1:
1: d608d2faa86 ! 1: 5d6d6658633 fsck: verify checksums of all .bitmap files
@@ pack-bitmap.c: int bitmap_is_preferred_refname(struct repository *r, const char
+ int fd = git_open(name);
+ int res = 0;
+
-+ /* A non-existent file is valid. */
-+ if (fstat(fd, &st)) {
-+ close(fd);
++ /* It is OK to not have the file. */
++ if (fd < 0 || fstat(fd, &st)) {
++ if (fd >= 0)
++ close(fd);
+ return 0;
+ }
+
@@ t/t5326-multi-pack-bitmaps.sh: test_expect_success 'tagged commits are selected
+ cp "$packbitmap.bak" "$packbitmap" &&
+
+ # fsck works at first
-+ git fsck &&
++ git fsck 2>err &&
++ test_must_be_empty err &&
+
+ corrupt_file "$packbitmap" &&
+ test_must_fail git fsck 2>err &&
@@ t/t5326-multi-pack-bitmaps.sh: test_expect_success 'tagged commits are selected
+ cp "$packbitmap.bak" "$packbitmap" &&
+ corrupt_file "$midxbitmap" &&
+ test_must_fail git fsck 2>err &&
-+ grep "bitmap file '\''$midxbitmap'\'' has invalid checksum" err
++ grep "bitmap file '\''$midxbitmap'\'' has invalid checksum" err &&
++
++ corrupt_file "$packbitmap" &&
++ test_must_fail git fsck 2>err &&
++ grep "bitmap file '\''$midxbitmap'\'' has invalid checksum" err &&
++ grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err
+'
+
test_done
2: 2162a352a46 = 2: 00789bbc558 fsck: use local repository
--
gitgitgadget
next prev parent reply other threads:[~2023-05-02 13:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-01 18:21 [PATCH 0/2] fsck: verify .bitmap checksums, cleanup Derrick Stolee via GitGitGadget
2023-05-01 18:21 ` [PATCH 1/2] fsck: verify checksums of all .bitmap files Derrick Stolee via GitGitGadget
2023-05-01 19:07 ` Junio C Hamano
2023-05-01 18:21 ` [PATCH 2/2] fsck: use local repository Derrick Stolee via GitGitGadget
2023-05-01 19:10 ` Junio C Hamano
2023-05-02 13:27 ` Derrick Stolee via GitGitGadget [this message]
2023-05-02 13:27 ` [PATCH v2 1/2] fsck: verify checksums of all .bitmap files Derrick Stolee via GitGitGadget
2023-05-02 13:27 ` [PATCH v2 2/2] fsck: use local repository Derrick Stolee via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.1526.v2.git.1683034042.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).