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

[PATCH/RFC 2/7] pack-objects: add sparse-prefix

From
RRRobin Ruede <r.ruede@gmail.com>
Date
Jul 28, 2016, 16:02 UTC
Message-ID
<20160728160226.24018-3-r.ruede@gmail.com>
In-Reply-To
<20160728160226.24018-1-r.ruede@gmail.com>

this allows creating packs that contain only the blobs relevant to a specific subdirectory, e.g.

    echo HEAD | git pack-objects --revs --sparse-prefix=/contrib/

will create a pack containing the complete history of HEAD, including all commits, all trees, and the files in the contrib directory.

Signed-off-by: Robin Ruede <r.ruede@gmail.com>
---
 builtin/pack-objects.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index a2f8cfd..0674f57 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2621,6 +2621,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 	struct argv_array rp = ARGV_ARRAY_INIT;
 	int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
 	int rev_list_index = 0;
+	const char *sparse_prefix = NULL;
+
 	struct option pack_objects_options[] = {
 		OPT_SET_INT('q', "quiet", &progress,
 			    N_("do not show progress meter"), 0),
@@ -2685,6 +2687,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 			 N_("create thin packs")),
 		OPT_BOOL(0, "shallow", &shallow,
 			 N_("create packs suitable for shallow fetches")),
+		OPT_STRING(0, "sparse-prefix", &sparse_prefix, N_("path"),
+		  N_("only include blobs relevant for sparse checkout (implies --revs)")),
 		OPT_BOOL(0, "honor-pack-keep", &ignore_packed_keep,
 			 N_("ignore packs that have companion .keep file")),
 		OPT_INTEGER(0, "compression", &pack_compression_level,
@@ -2725,6 +2729,13 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 	} else
 		argv_array_push(&rp, "--objects");
 
+	if (sparse_prefix) {
+		use_internal_rev_list = 1;
+		// with bitmaps the path of the blobs is not known
+		use_bitmap_index = 0;
+		argv_array_push(&rp, "--sparse-prefix");
+		argv_array_push(&rp, sparse_prefix);
+	}
 	if (rev_list_all) {
 		use_internal_rev_list = 1;
 		argv_array_push(&rp, "--all");
-- 
2.9.1.283.g3ca5b4c.dirty
Previous: Robin RuedeNext: Robin Ruede
Message 3 of 12 in “Add possibility to clone specific subdirectories”
  1. 0/7 Add possibility to clone specific subdirectoriesRobin Ruede, Jul 28, 2016
  2. 1/7 list-objects: add sparse-prefix option to rev_infoRobin Ruede, Jul 28, 2016
  3. 2/7 pack-objects: add sparse-prefixRobin Ruede, Jul 28, 2016
  4. 3/7 Skip checking integrity of files ignored by sparseRobin Ruede, Jul 28, 2016
  5. 5/7 fetch: add sparse-prefix optionRobin Ruede, Jul 28, 2016
  6. 6/7 clone: add sparse-prefix optionRobin Ruede, Jul 28, 2016
  7. 4/7 fetch-pack: add sparse prefix to smart protocolRobin Ruede, Jul 28, 2016
  8. 7/7 remote-curl: add sparse prefixRobin Ruede, Jul 28, 2016
  9. Duy NguyenJul 28, 2016
  10. Duy NguyenJul 28, 2016
  11. Junio C HamanoJul 28, 2016
  12. Duy NguyenJul 29, 2016

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.