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

[PATCH 1/3] fetch.fsckobjects: verify downloaded objects

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 5, 2011, 02:21 UTC
Message-ID
<1315189297-19497-2-git-send-email-gitster@pobox.com>
In-Reply-To
<1315189297-19497-1-git-send-email-gitster@pobox.com>

This corresponds to receive.fsckobjects configuration variable added (a lot) earlier in 20dc001 (receive-pack: allow using --strict mode for unpacking objects, 2008-02-25).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/config.txt |    6 ++++++
 builtin/fetch-pack.c     |    8 ++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 664de6b..4cbc4b9 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -820,6 +820,12 @@ diff.wordRegex::
 	sequences that match the regular expression are "words", all other
 	characters are *ignorable* whitespace.
 
+fetch.fsckObjects::
+	If it is set to true, git-fetch-pack will check all fetched
+	objects. It will abort in the case of a malformed object or a
+	broken link. The result of an abort are only dangling objects.
+	Defaults to false.
+
 fetch.unpackLimit::
 	If the number of objects fetched over the git native
 	transfer is below this
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index dbd8b7b..df6a8dc 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -14,6 +14,7 @@ static int transfer_unpack_limit = -1;
 static int fetch_unpack_limit = -1;
 static int unpack_limit = 100;
 static int prefer_ofs_delta = 1;
+static int fetch_fsck_objects;
 static struct fetch_pack_args args = {
 	/* .uploadpack = */ "git-upload-pack",
 };
@@ -663,6 +664,8 @@ static int get_pack(int xd[2], char **pack_lockfile)
 	}
 	if (*hdr_arg)
 		*av++ = hdr_arg;
+	if (fetch_fsck_objects)
+		*av++ = "--strict";
 	*av++ = NULL;
 
 	cmd.in = demux.out;
@@ -776,6 +779,11 @@ static int fetch_pack_config(const char *var, const char *value, void *cb)
 		return 0;
 	}
 
+	if (!strcmp(var, "fetch.fsckobjects")) {
+		fetch_fsck_objects = git_config_bool(var, value);
+		return 0;
+	}
+
 	return git_default_config(var, value, cb);
 }
 
-- 
1.7.7.rc0.175.gb3212
Previous: Junio C HamanoNext: Junio C Hamano
Message 16 of 18 in “Funnies with "git fetch"”
  1. Junio C HamanoSep 1, 2011
  2. Junio C HamanoSep 1, 2011
  3. Jeff KingSep 1, 2011
  4. Junio C HamanoSep 2, 2011
  5. Junio C HamanoSep 2, 2011
  6. Jeff KingSep 2, 2011
  7. 0/3 Verify the objects fetch obtained before updating refJunio C Hamano, Sep 1, 2011
  8. 1/3 list-objects: pass callback data to show_objects()Junio C Hamano, Sep 1, 2011
  9. 2/3 rev-list --verify-objectJunio C Hamano, Sep 1, 2011
  10. 3/3 fetch: verify we have everything we need before updating our refJunio C Hamano, Sep 1, 2011
  11. Nguyen Thai Ngoc DuySep 2, 2011
  12. Junio C HamanoSep 2, 2011
  13. Junio C HamanoSep 2, 2011
  14. Junio C HamanoSep 4, 2011
  15. 0/3 Add fetch.fsckobjectsJunio C Hamano, Sep 5, 2011
  16. 1/3 fetch.fsckobjects: verify downloaded objectsJunio C Hamano, Sep 5, 2011
  17. 2/3 transfer.fsckobjects: unify fetch/receive.fsckobjectsJunio C Hamano, Sep 5, 2011
  18. 3/3 test: fetch/receive with fsckobjectsJunio C Hamano, Sep 5, 2011

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.