From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 1/2] t1450: robustify `remove_object()`
Date: Wed, 10 Feb 2021 18:01:29 +0000 [thread overview]
Message-ID: <24d43d121162a9052f31c760a5fc929fdaad76b5.1612980090.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.874.git.1612980090.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
This function can be simplified by using the `test_oid_to_path()`
helper, which incidentally also makes it more robust by not relying on
the exact file system layout of the loose object files.
While at it, do not define those functions in a test case, it buys us
nothing.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
t/t1450-fsck.sh | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 02478bc4ece2..779f700ac4a0 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -41,17 +41,13 @@ test_expect_success 'HEAD is part of refs, valid objects appear valid' '
# specific corruption you test afterwards, lest a later test trip over
# it.
-test_expect_success 'setup: helpers for corruption tests' '
- sha1_file() {
- remainder=${1#??} &&
- firsttwo=${1%$remainder} &&
- echo ".git/objects/$firsttwo/$remainder"
- } &&
+sha1_file () {
+ git rev-parse --git-path objects/$(test_oid_to_path "$1")
+}
- remove_object() {
- rm "$(sha1_file "$1")"
- }
-'
+remove_object() {
+ rm "$(sha1_file "$1")"
+}
test_expect_success 'object with bad sha1' '
sha=$(echo blob | git hash-object -w --stdin) &&
--
gitgitgadget
next prev parent reply other threads:[~2021-02-10 18:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-10 18:01 [PATCH 0/2] Fix fsck --name-objects bug Johannes Schindelin via GitGitGadget
2021-02-10 18:01 ` Johannes Schindelin via GitGitGadget [this message]
2021-02-10 20:36 ` [PATCH 1/2] t1450: robustify `remove_object()` Junio C Hamano
2021-02-10 23:20 ` Taylor Blau
2021-02-11 0:10 ` Junio C Hamano
2021-02-10 18:01 ` [PATCH 2/2] fsck --name-objects: be more careful parsing generation numbers Johannes Schindelin via GitGitGadget
2021-02-10 20:38 ` Junio C Hamano
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=24d43d121162a9052f31c760a5fc929fdaad76b5.1612980090.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/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).