From: Robin Ruede <r.ruede@gmail.com>
To: git@vger.kernel.org
Cc: Robin Ruede <r.ruede@gmail.com>
Subject: [PATCH/RFC 1/7] list-objects: add sparse-prefix option to rev_info
Date: Thu, 28 Jul 2016 18:02:20 +0200 [thread overview]
Message-ID: <20160728160226.24018-2-r.ruede@gmail.com> (raw)
In-Reply-To: <20160728160226.24018-1-r.ruede@gmail.com>
this skips all blob objects who's path does not begin with the specified
prefix
Signed-off-by: Robin Ruede <r.ruede@gmail.com>
---
list-objects.c | 4 +++-
revision.c | 4 ++++
revision.h | 1 +
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/list-objects.c b/list-objects.c
index f3ca6aa..91a6091 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -28,7 +28,9 @@ static void process_blob(struct rev_info *revs,
pathlen = path->len;
strbuf_addstr(path, name);
- show(obj, path->buf, cb_data);
+ if (!revs->sparse_prefix || starts_with(path->buf, revs->sparse_prefix + 1)) {
+ show(obj, path->buf, cb_data);
+ }
strbuf_setlen(path, pathlen);
}
diff --git a/revision.c b/revision.c
index edba5b7..a36a796 100644
--- a/revision.c
+++ b/revision.c
@@ -1664,6 +1664,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
} else if ((argcount = parse_long_opt("skip", argv, &optarg))) {
revs->skip_count = atoi(optarg);
return argcount;
+ } else if ((argcount = parse_long_opt("sparse-prefix", argv, &optarg))) {
+ if(optarg[0] != '/') return error(N_("sparse prefix must start with /"));
+ revs->sparse_prefix = optarg;
+ return argcount;
} else if ((*arg == '-') && isdigit(arg[1])) {
/* accept -<digit>, like traditional "head" */
if (strtol_i(arg + 1, 10, &revs->max_count) < 0 ||
diff --git a/revision.h b/revision.h
index 9fac1a6..2c7c5f2 100644
--- a/revision.h
+++ b/revision.h
@@ -113,6 +113,7 @@ struct rev_info {
ancestry_path:1,
first_parent_only:1,
line_level_traverse:1;
+ const char *sparse_prefix;
/* Diff flags */
unsigned int diff:1,
--
2.9.1.283.g3ca5b4c.dirty
next prev parent reply other threads:[~2016-07-28 16:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-28 16:02 [PATCH/RFC 0/7] Add possibility to clone specific subdirectories Robin Ruede
2016-07-28 16:02 ` Robin Ruede [this message]
2016-07-28 16:02 ` [PATCH/RFC 2/7] pack-objects: add sparse-prefix Robin Ruede
2016-07-28 16:02 ` [PATCH/RFC 3/7] Skip checking integrity of files ignored by sparse Robin Ruede
2016-07-28 16:02 ` [PATCH/RFC 4/7] fetch-pack: add sparse prefix to smart protocol Robin Ruede
2016-07-28 16:02 ` [PATCH/RFC 5/7] fetch: add sparse-prefix option Robin Ruede
2016-07-28 16:02 ` [PATCH/RFC 6/7] clone: " Robin Ruede
2016-07-28 16:02 ` [PATCH/RFC 7/7] remote-curl: add sparse prefix Robin Ruede
2016-07-28 16:59 ` [PATCH/RFC 0/7] Add possibility to clone specific subdirectories Duy Nguyen
2016-07-28 17:03 ` Duy Nguyen
2016-07-28 20:33 ` Junio C Hamano
2016-07-29 15:51 ` Duy Nguyen
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160728160226.24018-2-r.ruede@gmail.com \
--to=r.ruede@gmail.com \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).