summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-12-16 12:49:35 -0800
committerJunio C Hamano <gitster@pobox.com>2010-12-16 12:49:35 -0800
commitb720c75afde3d813588fdfc84f762ef947f5587a (patch)
treefb9ba69d2ea32c9c3269b7365eefa7d9b4c92f4e
parentf1f76776fa932ca9f5b0a450707ee30b37b97bad (diff)
parent8e9d453ce77b7942dd35c23e145981dc472fb8c8 (diff)
downloadgit-b720c75afde3d813588fdfc84f762ef947f5587a.tar.gz
Merge branch 'jn/maint-svn-fe'
* jn/maint-svn-fe: t9010 fails when no svn is available vcs-svn: fix intermittent repo_tree corruption treap: make treap_insert return inserted node t9010 (svn-fe): Eliminate dependency on svn perl bindings
-rwxr-xr-xt/t9010-svn-fe.sh20
-rw-r--r--test-treap.c11
-rw-r--r--vcs-svn/repo_tree.c4
-rw-r--r--vcs-svn/trp.h3
-rw-r--r--vcs-svn/trp.txt10
5 files changed, 38 insertions, 10 deletions
diff --git a/t/t9010-svn-fe.sh b/t/t9010-svn-fe.sh
index a713dfc50b..faf9092967 100755
--- a/t/t9010-svn-fe.sh
+++ b/t/t9010-svn-fe.sh
@@ -2,9 +2,25 @@
test_description='check svn dumpfile importer'
-. ./lib-git-svn.sh
+. ./test-lib.sh
-test_dump() {
+if ! svnadmin -h >/dev/null 2>&1
+then
+ skip_all='skipping svn-fe tests, svn not available'
+ test_done
+fi
+
+svnconf=$PWD/svnconf
+export svnconf
+
+svn_cmd () {
+ subcommand=$1 &&
+ shift &&
+ mkdir -p "$svnconf" &&
+ svn "$subcommand" --config-dir "$svnconf" "$@"
+}
+
+test_dump () {
label=$1
dump=$2
test_expect_success "$dump" '
diff --git a/test-treap.c b/test-treap.c
index cdba5111e1..ab8c951c6e 100644
--- a/test-treap.c
+++ b/test-treap.c
@@ -38,9 +38,14 @@ int main(int argc, char *argv[])
usage("test-treap < ints");
while (strbuf_getline(&sb, stdin, '\n') != EOF) {
- item = node_alloc(1);
- strtonode(node_pointer(item), sb.buf);
- treap_insert(&root, node_pointer(item));
+ struct int_node *node = node_pointer(node_alloc(1));
+
+ item = node_offset(node);
+ strtonode(node, sb.buf);
+ node = treap_insert(&root, node_pointer(item));
+ if (node_offset(node) != item)
+ die("inserted %"PRIu32" in place of %"PRIu32"",
+ node_offset(node), item);
}
item = node_offset(treap_first(&root));
diff --git a/vcs-svn/repo_tree.c b/vcs-svn/repo_tree.c
index e94d91d129..e3d1fa3544 100644
--- a/vcs-svn/repo_tree.c
+++ b/vcs-svn/repo_tree.c
@@ -131,7 +131,7 @@ static void repo_write_dirent(uint32_t *path, uint32_t mode,
if (dent == key) {
dent->mode = REPO_MODE_DIR;
dent->content_offset = 0;
- dent_insert(&dir->entries, dent);
+ dent = dent_insert(&dir->entries, dent);
}
if (dent_offset(dent) < dent_pool.committed) {
@@ -142,7 +142,7 @@ static void repo_write_dirent(uint32_t *path, uint32_t mode,
dent->name_offset = name;
dent->mode = REPO_MODE_DIR;
dent->content_offset = dir_o;
- dent_insert(&dir->entries, dent);
+ dent = dent_insert(&dir->entries, dent);
}
dir = repo_dir_from_dirent(dent);
diff --git a/vcs-svn/trp.h b/vcs-svn/trp.h
index ee35c688a0..c32b9184e9 100644
--- a/vcs-svn/trp.h
+++ b/vcs-svn/trp.h
@@ -188,11 +188,12 @@ a_attr uint32_t MAYBE_UNUSED a_pre##insert_recurse(uint32_t cur_node, uint32_t i
return ret; \
} \
} \
-a_attr void MAYBE_UNUSED a_pre##insert(struct trp_root *treap, a_type *node) \
+a_attr a_type *MAYBE_UNUSED a_pre##insert(struct trp_root *treap, a_type *node) \
{ \
uint32_t offset = trpn_offset(a_base, node); \
trp_node_new(a_base, a_field, offset); \
treap->trp_root = a_pre##insert_recurse(treap->trp_root, offset); \
+ return trpn_pointer(a_base, offset); \
} \
a_attr uint32_t MAYBE_UNUSED a_pre##remove_recurse(uint32_t cur_node, uint32_t rem_node) \
{ \
diff --git a/vcs-svn/trp.txt b/vcs-svn/trp.txt
index eb4c191875..5ca6b42edb 100644
--- a/vcs-svn/trp.txt
+++ b/vcs-svn/trp.txt
@@ -21,7 +21,9 @@ The caller:
. Allocates a `struct trp_root` variable and sets it to {~0}.
-. Adds new nodes to the set using `foo_insert`.
+. Adds new nodes to the set using `foo_insert`. Any pointers
+ to existing nodes cannot be relied upon any more, so the caller
+ might retrieve them anew with `foo_pointer`.
. Can find a specific item in the set using `foo_search`.
@@ -73,10 +75,14 @@ int (*cmp)(node_type \*a, node_type \*b)
and returning a value less than, equal to, or greater than zero
according to the result of comparison.
-void foo_insert(struct trp_root *treap, node_type \*node)::
+node_type {asterisk}foo_insert(struct trp_root *treap, node_type \*node)::
Insert node into treap. If inserted multiple times,
a node will appear in the treap multiple times.
++
+The return value is the address of the node within the treap,
+which might differ from `node` if `pool_alloc` had to call
+`realloc` to expand the pool.
void foo_remove(struct trp_root *treap, node_type \*node)::