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

[PATCH 1/2] t1450: robustify `remove_object()`

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 10, 2021, 18:01 UTC
Message-ID
<24d43d121162a9052f31c760a5fc929fdaad76b5.1612980090.git.gitgitgadget@gmail.com>
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
Previous: Johannes Schindelin via GitGitGadgetNext: Junio C Hamano
Message 2 of 7 in “Fix fsck --name-objects bug”
  1. 0/2 Fix fsck --name-objects bugJohannes Schindelin via GitGitGadget, Feb 10, 2021
  2. 1/2 t1450: robustify `remove_object()`Johannes Schindelin via GitGitGadget, Feb 10, 2021
  3. Junio C HamanoFeb 10, 2021
  4. Taylor BlauFeb 10, 2021
  5. Junio C HamanoFeb 11, 2021
  6. 2/2 fsck --name-objects: be more careful parsing generation numbersJohannes Schindelin via GitGitGadget, Feb 10, 2021
  7. Junio C HamanoFeb 10, 2021

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.