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

[PATCH 11/11] fsck: verify multi-pack-index

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Sep 5, 2018, 14:46 UTC
Message-ID
<09d16aff20fc16768e688c109519e4e41f9a8e36.1536158789.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.34.git.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>

When core.multiPackIndex is true, we may have a multi-pack-index in our object directory. Add calls to 'git multi-pack-index verify' at the end of 'git fsck' if so.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 builtin/fsck.c              | 18 ++++++++++++++++++
 t/t5319-multi-pack-index.sh | 13 ++++++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 63c8578cc1..06eb421720 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -848,5 +848,23 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 		}
 	}
 
+	if (!git_config_get_bool("core.multipackindex", &i) && i) {
+		struct child_process midx_verify = CHILD_PROCESS_INIT;
+		const char *midx_argv[] = { "multi-pack-index", "verify", NULL, NULL, NULL };
+
+		midx_verify.argv = midx_argv;
+		midx_verify.git_cmd = 1;
+		if (run_command(&midx_verify))
+			errors_found |= ERROR_COMMIT_GRAPH;
+
+		prepare_alt_odb(the_repository);
+		for (alt =  the_repository->objects->alt_odb_list; alt; alt = alt->next) {
+			midx_argv[2] = "--object-dir";
+			midx_argv[3] = alt->path;
+			if (run_command(&midx_verify))
+				errors_found |= ERROR_COMMIT_GRAPH;
+		}
+	}
+
 	return errors_found;
 }
diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh
index b6c34631d3..63f8718fd7 100755
--- a/t/t5319-multi-pack-index.sh
+++ b/t/t5319-multi-pack-index.sh
@@ -160,12 +160,17 @@ corrupt_midx_and_verify() {
 	DATA="${2:-\0}"
 	OBJDIR=$3
 	GREPSTR="$4"
+	COMMAND="$5"
+	if test -z "$COMMAND"
+	then
+		COMMAND="git multi-pack-index verify --object-dir=$OBJDIR"
+	fi
 	FILE=$OBJDIR/pack/multi-pack-index &&
 	chmod a+w $FILE &&
 	test_when_finished mv midx-backup $FILE &&
 	cp $FILE midx-backup &&
 	printf "$DATA" | dd of="$FILE" bs=1 seek="$POS" conv=notrunc &&
-	test_must_fail git multi-pack-index verify --object-dir=$OBJDIR 2>test_err &&
+	test_must_fail $COMMAND 2>test_err &&
 	grep -v "^+" test_err >err &&
 	test_i18ngrep "$GREPSTR" err
 }
@@ -258,6 +263,12 @@ test_expect_success 'verify incorrect offset' '
 		"incorrect object offset"
 '
 
+test_expect_success 'git-fsck incorrect offset' '
+	corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\07" $objdir \
+		"incorrect object offset" \
+		"git -c core.multipackindex=true fsck"
+'
+
 test_expect_success 'repack removes multi-pack-index' '
 	test_path_is_file $objdir/pack/multi-pack-index &&
 	git repack -adf &&
-- 
gitgitgadget
Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee via GitGitGadget
Message 21 of 34 in “Add 'git multi-pack-index verify' command”
  1. 00/11 Add 'git multi-pack-index verify' commandDerrick Stolee via GitGitGadget, Sep 5, 2018
  2. 01/11 multi-pack-index: add 'verify' verbDerrick Stolee via GitGitGadget, Sep 5, 2018
  3. Eric SunshineSep 5, 2018
  4. Derrick StoleeSep 5, 2018
  5. 02/11 multi-pack-index: verify bad headerDerrick Stolee via GitGitGadget, Sep 5, 2018
  6. Eric SunshineSep 7, 2018
  7. 04/11 multi-pack-index: verify packname orderDerrick Stolee via GitGitGadget, Sep 5, 2018
  8. Stefan BellerSep 5, 2018
  9. Derrick StoleeSep 5, 2018
  10. Stefan BellerSep 5, 2018
  11. Derrick StoleeSep 5, 2018
  12. 05/11 multi-pack-index: verify missing packDerrick Stolee via GitGitGadget, Sep 5, 2018
  13. 06/11 multi-pack-index: verify oid fanout orderDerrick Stolee via GitGitGadget, Sep 5, 2018
  14. 07/11 multi-pack-index: verify oid lookup orderDerrick Stolee via GitGitGadget, Sep 5, 2018
  15. 08/11 multi-pack-index: fix 32-bit vs 64-bit size checkDerrick Stolee via GitGitGadget, Sep 5, 2018
  16. 03/11 multi-pack-index: verify corrupt chunk lookup tableDerrick Stolee via GitGitGadget, Sep 5, 2018
  17. 09/11 multi-pack-index: verify object offsetsDerrick Stolee via GitGitGadget, Sep 5, 2018
  18. Eric SunshineSep 7, 2018
  19. Derrick StoleeSep 7, 2018
  20. 10/11 multi-pack-index: report progress during 'verify'Derrick Stolee via GitGitGadget, Sep 5, 2018
  21. 11/11 fsck: verify multi-pack-indexDerrick Stolee via GitGitGadget, Sep 5, 2018
  22. 00/11 Add 'git multi-pack-index verify' commandDerrick Stolee via GitGitGadget, Sep 13, 2018
  23. 02/11 multi-pack-index: verify bad headerDerrick Stolee via GitGitGadget, Sep 13, 2018
  24. 03/11 multi-pack-index: verify corrupt chunk lookup tableDerrick Stolee via GitGitGadget, Sep 13, 2018
  25. 04/11 multi-pack-index: verify packname orderDerrick Stolee via GitGitGadget, Sep 13, 2018
  26. 05/11 multi-pack-index: verify missing packDerrick Stolee via GitGitGadget, Sep 13, 2018
  27. 06/11 multi-pack-index: verify oid fanout orderDerrick Stolee via GitGitGadget, Sep 13, 2018
  28. 07/11 multi-pack-index: verify oid lookup orderDerrick Stolee via GitGitGadget, Sep 13, 2018
  29. 08/11 multi-pack-index: fix 32-bit vs 64-bit size checkDerrick Stolee via GitGitGadget, Sep 13, 2018
  30. 09/11 multi-pack-index: verify object offsetsDerrick Stolee via GitGitGadget, Sep 13, 2018
  31. 10/11 multi-pack-index: report progress during 'verify'Derrick Stolee via GitGitGadget, Sep 13, 2018
  32. Ævar Arnfjörð BjarmasonSep 13, 2018
  33. 11/11 fsck: verify multi-pack-indexDerrick Stolee via GitGitGadget, Sep 13, 2018
  34. 01/11 multi-pack-index: add 'verify' verbDerrick Stolee via GitGitGadget, Sep 13, 2018

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.