From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: pclouds@gmail.com, Elijah Newren <newren@gmail.com>
Subject: [RFC PATCH 04/15] When unpacking in a sparse repository, avoid traversing missing trees/blobs
Date: Sat, 4 Sep 2010 18:13:56 -0600 [thread overview]
Message-ID: <1283645647-1891-5-git-send-email-newren@gmail.com> (raw)
In-Reply-To: <1283645647-1891-1-git-send-email-newren@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
---
diff.h | 1 -
t/t5720-sparse-repository-basics.sh | 10 +++---
tree-diff.c | 2 +-
tree-walk.c | 48 ++++++++++++++++++++++++++++++----
tree-walk.h | 3 ++
5 files changed, 51 insertions(+), 13 deletions(-)
diff --git a/diff.h b/diff.h
index 986a015..e17383c 100644
--- a/diff.h
+++ b/diff.h
@@ -171,7 +171,6 @@ extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
const char *base, struct diff_options *opt);
extern int diff_root_tree_sha1(const unsigned char *new, const char *base,
struct diff_options *opt);
-extern int tree_entry_interesting(struct tree_desc *desc, const char *base, int baselen, struct diff_options *opt);
struct combine_diff_path {
struct combine_diff_path *next;
diff --git a/t/t5720-sparse-repository-basics.sh b/t/t5720-sparse-repository-basics.sh
index b8e9a3a..b946c23 100755
--- a/t/t5720-sparse-repository-basics.sh
+++ b/t/t5720-sparse-repository-basics.sh
@@ -41,7 +41,7 @@ test_expect_success 'setup' '
)
'
-test_expect_failure 'make sparse repository' '
+test_expect_success 'make sparse repository' '
git clone -q "file://$(pwd)/src" dst &&
(
cd dst &&
@@ -55,7 +55,7 @@ test_expect_failure 'make sparse repository' '
cd dst 2>/dev/null || test_done
srcgit="--git-dir=../src/.git"
-test_expect_failure 'plumbing: ls-files works' '
+test_expect_success 'plumbing: ls-files works' '
git ls-files > output &&
test "sub/b/file" = "$(cat output)"
'
@@ -98,19 +98,19 @@ test_expect_failure 'basic: diff works' '
git diff master~3
'
-test_expect_failure 'basic: checkout works' '
+test_expect_success 'basic: checkout works' '
git checkout master~2 &&
git checkout master
'
-test_expect_failure 'basic: status works with modified stuff' '
+test_expect_success 'basic: status works with modified stuff' '
git status &&
echo more content >> sub/b/file &&
echo newfile content >> sub/b/whatever &&
git status
'
-test_expect_failure 'basic: add works' '
+test_expect_success 'basic: add works' '
git add sub/b/file &&
git add sub/b/whatever
'
diff --git a/tree-diff.c b/tree-diff.c
index 951b53b..95e956e 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -261,7 +261,7 @@ static void show_entry(struct diff_options *opt, const char *prefix, struct tree
}
}
-static void skip_uninteresting(struct tree_desc *t, const char *base, int baselen, struct diff_options *opt, int *all_interesting)
+void skip_uninteresting(struct tree_desc *t, const char *base, int baselen, struct diff_options *opt, int *all_interesting)
{
while (t->size) {
int show = tree_entry_interesting(t, base, baselen, opt);
diff --git a/tree-walk.c b/tree-walk.c
index a9bbf4e..a584dd8 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -66,8 +66,19 @@ static void entry_clear(struct name_entry *a)
memset(a, 0, sizeof(*a));
}
-static void entry_extract(struct tree_desc *t, struct name_entry *a)
+struct tree_sparse_info {
+ int all_interesting;
+ const char *base;
+ int baselen;
+ struct diff_options *diffopt; /* really is const too */
+};
+
+static void entry_extract(struct tree_desc *t, struct name_entry *a,
+ struct tree_sparse_info *i)
{
+ if (!i->all_interesting)
+ skip_uninteresting(t, i->base, i->baselen,
+ i->diffopt, &i->all_interesting);
*a = t->entry;
}
@@ -219,7 +230,8 @@ static int check_entry_match(const char *a, int a_len, const char *b, int b_len)
static void extended_entry_extract(struct tree_desc_x *t,
struct name_entry *a,
const char *first,
- int first_len)
+ int first_len,
+ struct tree_sparse_info *i)
{
const char *path;
int len;
@@ -235,7 +247,7 @@ static void extended_entry_extract(struct tree_desc_x *t,
entry_clear(a);
break; /* not found */
}
- entry_extract(&t->d, a);
+ entry_extract(&t->d, a, i);
for (skip = t->skip; skip; skip = skip->prev)
if (a->path == skip->ptr)
break; /* found */
@@ -268,7 +280,7 @@ static void extended_entry_extract(struct tree_desc_x *t,
*/
probe = t->d;
while (probe.size) {
- entry_extract(&probe, a);
+ entry_extract(&probe, a, i);
path = a->path;
len = tree_entry_len(a->path, a->sha1);
switch (check_entry_match(first, first_len, path, len)) {
@@ -315,6 +327,28 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
struct name_entry *entry = xmalloc(n*sizeof(*entry));
int i;
struct tree_desc_x *tx = xcalloc(n, sizeof(*tx));
+ char prefix[PATH_MAX];
+ struct tree_sparse_info sparse_info;
+ if (!git_sparse_pathspecs)
+ sparse_info.all_interesting = 1;
+ else {
+ if (info->prev)
+ make_traverse_path(prefix, info->prev, &info->name);
+ else
+ strcpy(prefix, info->name.path);
+ sparse_info.baselen = strlen(prefix);
+
+ /* prefix must be slash terminated if non-empty */
+ if (sparse_info.baselen) {
+ sparse_info.baselen += 1;
+ prefix[sparse_info.baselen-1] = '/';
+ prefix[sparse_info.baselen] = '\0';
+ }
+
+ sparse_info.all_interesting = 0;
+ sparse_info.base = prefix;
+ sparse_info.diffopt = &git_sparse_diffopts;
+ }
for (i = 0; i < n; i++)
tx[i].d = t[i];
@@ -328,7 +362,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
for (i = 0; i < n; i++) {
e = entry + i;
- extended_entry_extract(tx + i, e, NULL, 0);
+ extended_entry_extract(tx + i, e, NULL, 0, &sparse_info);
}
/*
@@ -356,7 +390,9 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
if (first) {
for (i = 0; i < n; i++) {
e = entry + i;
- extended_entry_extract(tx + i, e, first, first_len);
+ extended_entry_extract(tx + i, e,
+ first, first_len,
+ &sparse_info);
/* Cull the ones that are not the earliest */
if (!e->path)
continue;
diff --git a/tree-walk.h b/tree-walk.h
index 7e3e0b5..eae1997 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -60,4 +60,7 @@ static inline int traverse_path_len(const struct traverse_info *info, const stru
return info->pathlen + tree_entry_len(n->path, n->sha1);
}
+void skip_uninteresting(struct tree_desc *t, const char *base, int baselen, struct diff_options *opt, int *all_interesting);
+int tree_entry_interesting(struct tree_desc *desc, const char *base, int baselen, struct diff_options *opt);
+
#endif
--
1.7.2.2.140.gd06af
next prev parent reply other threads:[~2010-09-05 0:13 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-05 0:13 [RFC PATCH 00/15] Sparse clones Elijah Newren
2010-09-05 0:13 ` [RFC PATCH 01/15] README-sparse-clone: Add a basic writeup of my ideas for sparse clones Elijah Newren
2010-09-05 3:01 ` Nguyen Thai Ngoc Duy
2010-09-05 3:13 ` Elijah Newren
2010-09-06 3:14 ` Nguyen Thai Ngoc Duy
2010-09-05 0:13 ` [RFC PATCH 02/15] Add tests for client handling in a sparse repository Elijah Newren
2010-09-05 0:13 ` [RFC PATCH 03/15] Read sparse limiting args from $GIT_DIR/sparse-limit Elijah Newren
2010-09-05 0:13 ` Elijah Newren [this message]
2010-09-05 0:13 ` [RFC PATCH 05/15] read_tree_recursive: Avoid missing blobs and trees in a sparse repository Elijah Newren
2010-09-05 2:00 ` Nguyen Thai Ngoc Duy
2010-09-05 3:16 ` Elijah Newren
2010-09-05 4:31 ` Elijah Newren
2010-09-05 0:13 ` [RFC PATCH 06/15] Automatically reuse sparse limiting arguments in revision walking Elijah Newren
2010-09-05 1:58 ` Nguyen Thai Ngoc Duy
2010-09-05 4:50 ` Elijah Newren
2010-09-05 7:12 ` Nguyen Thai Ngoc Duy
2010-09-05 0:13 ` [RFC PATCH 07/15] cache_tree_update(): Capability to handle tree entries missing from index Elijah Newren
2010-09-05 7:54 ` Nguyen Thai Ngoc Duy
2010-09-05 21:09 ` Elijah Newren
2010-09-06 4:42 ` Elijah Newren
2010-09-06 5:02 ` Nguyen Thai Ngoc Duy
2010-09-06 4:47 ` [PATCH 0/4] en/object-list-with-pathspec update Nguyễn Thái Ngọc Duy
2010-09-06 4:47 ` [PATCH 1/4] Add testcases showing how pathspecs are ignored with rev-list --objects Nguyễn Thái Ngọc Duy
2010-09-06 4:47 ` [PATCH 2/4] tree-walk: copy tree_entry_interesting() as is from tree-diff.c Nguyễn Thái Ngọc Duy
2010-09-06 15:22 ` Elijah Newren
2010-09-06 22:09 ` Nguyen Thai Ngoc Duy
2010-09-06 4:47 ` [PATCH 3/4] tree-walk: actually move tree_entry_interesting() to tree-walk.c Nguyễn Thái Ngọc Duy
2010-09-06 15:31 ` Elijah Newren
2010-09-06 22:20 ` Nguyen Thai Ngoc Duy
2010-09-06 23:53 ` Junio C Hamano
2010-09-06 4:47 ` [PATCH 4/4] Make rev-list --objects work together with pathspecs Nguyễn Thái Ngọc Duy
2010-09-07 1:28 ` [RFC PATCH 07/15] cache_tree_update(): Capability to handle tree entries missing from index Nguyen Thai Ngoc Duy
2010-09-07 3:06 ` Elijah Newren
2010-09-05 0:14 ` [RFC PATCH 08/15] cache_tree_update(): Require relevant tree to be passed Elijah Newren
2010-09-05 0:14 ` [RFC PATCH 09/15] Add tests for communication dealing with sparse repositories Elijah Newren
2010-09-05 0:14 ` [RFC PATCH 10/15] sparse-repo: Provide a function to record sparse limiting arguments Elijah Newren
2010-09-05 0:14 ` [RFC PATCH 11/15] builtin-clone: Accept paths for sparse clone Elijah Newren
2010-09-05 0:14 ` [RFC PATCH 12/15] Pass extra (rev-list) args on, at least in some cases Elijah Newren
2010-09-05 0:14 ` [RFC PATCH 13/15] upload-pack: Handle extra rev-list arguments being passed Elijah Newren
2010-09-05 0:14 ` [RFC PATCH 14/15] EVIL COMMIT: Include all commits Elijah Newren
2010-09-05 0:14 ` [RFC PATCH 15/15] clone: Ensure sparse limiting arguments are used in subsequent operations 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=1283645647-1891-5-git-send-email-newren@gmail.com \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@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).