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

[PATCH v3 3/5] repack: add --sparse and pass to pack-objects

From
NFNathaniel Filardo <nwf20@cl.cam.ac.uk>
Date
Jun 24, 2019, 12:07 UTC
Message-ID
<20190624120711.27744-4-nwf20@cl.cam.ac.uk>
In-Reply-To
<20190624120711.27744-1-nwf20@cl.cam.ac.uk>
The sparse connectivity algorithm saves a whole lot of time when there
are UNINTERESTING trees around.
---
 Documentation/git-repack.txt   | 4 ++++
 builtin/repack.c               | 5 +++++
 t/t5322-pack-objects-sparse.sh | 6 ++++++
 3 files changed, 15 insertions(+)
diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index aa0cc8bd44..836d81457a 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -165,6 +165,10 @@ depth is 4095.
 	Pass the `--delta-islands` option to `git-pack-objects`, see
 	linkgit:git-pack-objects[1].
 
+--sparse::
+	Pass the `--sparse` option to `git-pack-objects`; see
+	linkgit:git-pack-objects[1].
+
 Configuration
 -------------
 
diff --git a/builtin/repack.c b/builtin/repack.c
index caca113927..4cfdd62bb8 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -288,6 +288,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 	int no_update_server_info = 0;
 	int midx_cleared = 0;
 	struct pack_objects_args po_args = {NULL};
+	int sparse = 0;
 
 	struct option builtin_repack_options[] = {
 		OPT_BIT('a', NULL, &pack_everything,
@@ -326,6 +327,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 				N_("maximum size of each packfile")),
 		OPT_BOOL(0, "pack-kept-objects", &pack_kept_objects,
 				N_("repack objects in packs marked with .keep")),
+		OPT_BOOL(0, "sparse", &sparse,
+			 N_("use the sparse reachability algorithm")),
 		OPT_STRING_LIST(0, "keep-pack", &keep_pack_list, N_("name"),
 				N_("do not repack this pack")),
 		OPT_END()
@@ -369,6 +372,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 	argv_array_push(&cmd.args, "--all");
 	argv_array_push(&cmd.args, "--reflog");
 	argv_array_push(&cmd.args, "--indexed-objects");
+	if (sparse)
+		argv_array_push(&cmd.args, "--sparse");
 	if (repository_format_partial_clone)
 		argv_array_push(&cmd.args, "--exclude-promisor-objects");
 	if (write_bitmaps)
diff --git a/t/t5322-pack-objects-sparse.sh b/t/t5322-pack-objects-sparse.sh
index 7124b5581a..66e133dcfe 100755
--- a/t/t5322-pack-objects-sparse.sh
+++ b/t/t5322-pack-objects-sparse.sh
@@ -133,4 +133,10 @@ test_expect_success 'pack.useSparse overridden' '
 	test_cmp required_objects.txt sparse_objects.txt
 '
 
+# repack --sparse invokes pack-objects --sparse
+test_expect_success 'repack --sparse and fsck' '
+	git repack -a --sparse &&
+	git fsck
+'
+
 test_done
-- 
2.17.1
Previous: Dr N.W. FilardoNext: Derrick Stolee
Message 5 of 11 in “Speed up repacking when lots of pack-kept objects”
  1. 0/5 Speed up repacking when lots of pack-kept objectsNathaniel Filardo, Jun 24, 2019
  2. 4/5 repack: optionally assume transitive kept packsNathaniel Filardo, Jun 24, 2019
  3. Derrick StoleeJun 24, 2019
  4. Dr N.W. FilardoJun 25, 2019
  5. 3/5 repack: add --sparse and pass to pack-objectsNathaniel Filardo, Jun 24, 2019
  6. Derrick StoleeJun 24, 2019
  7. 2/5 revision walk: optionally use sparse reachabilityNathaniel Filardo, Jun 24, 2019
  8. Derrick StoleeJun 24, 2019
  9. 1/5 count-objects: report statistics about kept packsNathaniel Filardo, Jun 24, 2019
  10. Derrick StoleeJun 24, 2019
  11. 5/5 builtin/gc: add --assume-pack-keep-transitiveNathaniel Filardo, Jun 24, 2019

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.