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

Re: Bug report - sparse-checkout ignores prefix when run in subdirectories

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 5, 2022, 22:38 UTC
Message-ID
<xmqqsfu1g64s.fsf@gitster.g>
In-Reply-To
<29f0410e-6dfa-2e86-394d-b1fb735e7608@gmail.com>
Lessley Dennington <lessleydennington@gmail.com> writes:
> Hello everyone! See the following bug report pertaining to sparse-checkout
> when run outside top-level directories.

In a bug report it is fine, but "outside top-level" usually means above the top-level of the working tree. Here, I think you meant running in a subdirectory of the top-level.

Perhaps something along this line?
 builtin/sparse-checkout.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git c/builtin/sparse-checkout.c w/builtin/sparse-checkout.c
index 45e838d8f8..4e5efbb85e 100644
--- c/builtin/sparse-checkout.c
+++ w/builtin/sparse-checkout.c
@@ -753,6 +753,16 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)
 	if (!core_sparse_checkout_cone && argc == 0) {
 		argv = default_patterns;
 		argc = default_patterns_nr;
+	} else if (argc && prefix && *prefix) {
+		/* 
+		 * The args are not pathspecs, so unfortunately we
+		 * cannot imitate how cmd_add() uses parse_pathspec().
+		 */
+		int i;
+		int prefix_len = strlen(prefix);
+
+		for (i = 0; i < argc; i++)
+			argv[i] = prefix_path(prefix, prefix_len, argv[i]);
 	}
 
 	return modify_pattern_list(argc, argv, set_opts.use_stdin, REPLACE);
Previous: Lessley DenningtonNext: Elijah Newren
Message 2 of 10 in “Bug report - sparse-checkout ignores prefix when run in subdirectories”
  1. Lessley DenningtonJan 5, 2022
  2. Junio C HamanoJan 5, 2022
  3. Elijah NewrenJan 5, 2022
  4. Junio C HamanoJan 5, 2022
  5. Elijah NewrenJan 6, 2022
  6. Junio C HamanoJan 6, 2022
  7. Elijah NewrenJan 6, 2022
  8. Junio C HamanoJan 6, 2022
  9. Derrick StoleeJan 27, 2022
  10. Elijah NewrenJan 27, 2022

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.