Skip to content

Commit b720c75

Browse files
committed
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
2 parents f1f7677 + 8e9d453 commit b720c75

File tree

5 files changed

+38
-10
lines changed

5 files changed

+38
-10
lines changed

t/t9010-svn-fe.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,25 @@
22

33
test_description='check svn dumpfile importer'
44

5-
. ./lib-git-svn.sh
5+
. ./test-lib.sh
66

7-
test_dump() {
7+
if ! svnadmin -h >/dev/null 2>&1
8+
then
9+
skip_all='skipping svn-fe tests, svn not available'
10+
test_done
11+
fi
12+
13+
svnconf=$PWD/svnconf
14+
export svnconf
15+
16+
svn_cmd () {
17+
subcommand=$1 &&
18+
shift &&
19+
mkdir -p "$svnconf" &&
20+
svn "$subcommand" --config-dir "$svnconf" "$@"
21+
}
22+
23+
test_dump () {
824
label=$1
925
dump=$2
1026
test_expect_success "$dump" '

test-treap.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,14 @@ int main(int argc, char *argv[])
3838
usage("test-treap < ints");
3939

4040
while (strbuf_getline(&sb, stdin, '\n') != EOF) {
41-
item = node_alloc(1);
42-
strtonode(node_pointer(item), sb.buf);
43-
treap_insert(&root, node_pointer(item));
41+
struct int_node *node = node_pointer(node_alloc(1));
42+
43+
item = node_offset(node);
44+
strtonode(node, sb.buf);
45+
node = treap_insert(&root, node_pointer(item));
46+
if (node_offset(node) != item)
47+
die("inserted %"PRIu32" in place of %"PRIu32"",
48+
node_offset(node), item);
4449
}
4550

4651
item = node_offset(treap_first(&root));

vcs-svn/repo_tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static void repo_write_dirent(uint32_t *path, uint32_t mode,
131131
if (dent == key) {
132132
dent->mode = REPO_MODE_DIR;
133133
dent->content_offset = 0;
134-
dent_insert(&dir->entries, dent);
134+
dent = dent_insert(&dir->entries, dent);
135135
}
136136

137137
if (dent_offset(dent) < dent_pool.committed) {
@@ -142,7 +142,7 @@ static void repo_write_dirent(uint32_t *path, uint32_t mode,
142142
dent->name_offset = name;
143143
dent->mode = REPO_MODE_DIR;
144144
dent->content_offset = dir_o;
145-
dent_insert(&dir->entries, dent);
145+
dent = dent_insert(&dir->entries, dent);
146146
}
147147

148148
dir = repo_dir_from_dirent(dent);

vcs-svn/trp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,12 @@ a_attr uint32_t MAYBE_UNUSED a_pre##insert_recurse(uint32_t cur_node, uint32_t i
188188
return ret; \
189189
} \
190190
} \
191-
a_attr void MAYBE_UNUSED a_pre##insert(struct trp_root *treap, a_type *node) \
191+
a_attr a_type *MAYBE_UNUSED a_pre##insert(struct trp_root *treap, a_type *node) \
192192
{ \
193193
uint32_t offset = trpn_offset(a_base, node); \
194194
trp_node_new(a_base, a_field, offset); \
195195
treap->trp_root = a_pre##insert_recurse(treap->trp_root, offset); \
196+
return trpn_pointer(a_base, offset); \
196197
} \
197198
a_attr uint32_t MAYBE_UNUSED a_pre##remove_recurse(uint32_t cur_node, uint32_t rem_node) \
198199
{ \

vcs-svn/trp.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ The caller:
2121

2222
. Allocates a `struct trp_root` variable and sets it to {~0}.
2323

24-
. Adds new nodes to the set using `foo_insert`.
24+
. Adds new nodes to the set using `foo_insert`. Any pointers
25+
to existing nodes cannot be relied upon any more, so the caller
26+
might retrieve them anew with `foo_pointer`.
2527

2628
. Can find a specific item in the set using `foo_search`.
2729

@@ -73,10 +75,14 @@ int (*cmp)(node_type \*a, node_type \*b)
7375
and returning a value less than, equal to, or greater than zero
7476
according to the result of comparison.
7577

76-
void foo_insert(struct trp_root *treap, node_type \*node)::
78+
node_type {asterisk}foo_insert(struct trp_root *treap, node_type \*node)::
7779

7880
Insert node into treap. If inserted multiple times,
7981
a node will appear in the treap multiple times.
82+
+
83+
The return value is the address of the node within the treap,
84+
which might differ from `node` if `pool_alloc` had to call
85+
`realloc` to expand the pool.
8086

8187
void foo_remove(struct trp_root *treap, node_type \*node)::
8288

0 commit comments

Comments
 (0)