git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Lessley Dennington <lessleydennington@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Elijah Newren <newren@gmail.com>,
	Derrick Stolee <stolee@gmail.com>
Subject: Re: Bug report - sparse-checkout ignores prefix when run in subdirectories
Date: Wed, 05 Jan 2022 14:38:43 -0800	[thread overview]
Message-ID: <xmqqsfu1g64s.fsf@gitster.g> (raw)
In-Reply-To: <29f0410e-6dfa-2e86-394d-b1fb735e7608@gmail.com> (Lessley Dennington's message of "Wed, 5 Jan 2022 14:13:22 -0600")

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);

  reply	other threads:[~2022-01-05 22:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05 20:13 Bug report - sparse-checkout ignores prefix when run in subdirectories Lessley Dennington
2022-01-05 22:38 ` Junio C Hamano [this message]
2022-01-05 23:19   ` Elijah Newren
2022-01-05 23:29     ` Junio C Hamano
2022-01-06  0:08       ` Elijah Newren
2022-01-06  0:17         ` Junio C Hamano
2022-01-06  1:08           ` Elijah Newren
2022-01-06 19:25             ` Junio C Hamano
2022-01-27 16:43     ` Derrick Stolee
2022-01-27 17:30       ` Elijah Newren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqsfu1g64s.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=lessleydennington@gmail.com \
    --cc=newren@gmail.com \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).