Skip to content

Commit 9bd80f4

Browse files
christian-schillingLMG
authored andcommitted
Fix prefix/subdir optimisation bug
The optimiser rule was wrong in case the subdir filter path was a prefix of the prefix filter. It resulted in :empty in this case, which is wrong. Change: fix-prefix-subdir
1 parent 612b1b7 commit 9bd80f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+59
-50
lines changed

src/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::*;
22
use std::collections::HashMap;
33

4-
const CACHE_VERSION: u64 = 13;
4+
const CACHE_VERSION: u64 = 14;
55

66
lazy_static! {
77
static ref DB: std::sync::Mutex<Option<sled::Db>> = std::sync::Mutex::new(None);

src/filter/opt.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,14 @@ fn step(filter: Filter) -> Filter {
353353
Op::Chain(a, b) => match (to_op(a), to_op(b)) {
354354
(Op::Chain(x, y), b) => Op::Chain(x, to_filter(Op::Chain(y, to_filter(b)))),
355355
(Op::Prefix(a), Op::Subdir(b)) if a == b => Op::Nop,
356-
(Op::Prefix(a), Op::Subdir(b)) if a != b => Op::Empty,
356+
(Op::Prefix(a), Op::Subdir(b))
357+
if a != b && a.components().count() == b.components().count() =>
358+
{
359+
Op::Empty
360+
}
361+
(Op::Prefix(a), Op::Subdir(b)) if a != b => {
362+
Op::Prefix(a.strip_prefix(&b).unwrap_or(&a).to_owned())
363+
}
357364
(Op::Nop, b) => b,
358365
(a, Op::Nop) => a,
359366
(Op::Empty, _) => Op::Empty,

tests/filter/pretty_print.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
:/"a%\"$"
1313
$ josh-filter -p :/a:/b
1414
:/a/b
15+
$ josh-filter -p :prefix=x/y:/x
16+
:prefix=y
1517
$ josh-filter -p :[:/a:/b,:/a/b]
1618
:/a/b
1719
$ josh-filter -p :[:empty,:/a]

tests/proxy/amend_patchset.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
"real_repo.git" = [':/sub3']
122122
.
123123
|-- josh
124-
| `-- 13
124+
| `-- 14
125125
| `-- sled
126126
| |-- blobs
127127
| |-- conf

tests/proxy/authentication.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"real_repo.git" = [':/sub1']
125125
.
126126
|-- josh
127-
| `-- 13
127+
| `-- 14
128128
| `-- sled
129129
| |-- blobs
130130
| |-- conf

tests/proxy/caching.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"real_repo.git" = [':/sub1']
4949
.
5050
|-- josh
51-
| `-- 13
51+
| `-- 14
5252
| `-- sled
5353
| |-- blobs
5454
| |-- conf
@@ -156,7 +156,7 @@
156156
"real_repo.git" = [':/sub1']
157157
.
158158
|-- josh
159-
| `-- 13
159+
| `-- 14
160160
| `-- sled
161161
| |-- blobs
162162
| |-- conf

tests/proxy/clone_absent_head.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
$ bash ${TESTDIR}/destroy_test_env.sh
8888
.
8989
|-- josh
90-
| `-- 13
90+
| `-- 14
9191
| `-- sled
9292
| |-- blobs
9393
| |-- conf

tests/proxy/clone_all.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"real_repo.git" = [':/sub1']
5454
.
5555
|-- josh
56-
| `-- 13
56+
| `-- 14
5757
| `-- sled
5858
| |-- blobs
5959
| |-- conf

tests/proxy/clone_blocked.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
$ bash ${TESTDIR}/destroy_test_env.sh
1010
.
1111
|-- josh
12-
| `-- 13
12+
| `-- 14
1313
| `-- sled
1414
| |-- blobs
1515
| |-- conf

tests/proxy/clone_invalid_url.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
$ bash ${TESTDIR}/destroy_test_env.sh
3333
.
3434
|-- josh
35-
| `-- 13
35+
| `-- 14
3636
| `-- sled
3737
| |-- blobs
3838
| |-- conf

tests/proxy/clone_locked_refs.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
]
112112
.
113113
|-- josh
114-
| `-- 13
114+
| `-- 14
115115
| `-- sled
116116
| |-- blobs
117117
| |-- conf

tests/proxy/clone_prefix.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
]
7575
.
7676
|-- josh
77-
| `-- 13
77+
| `-- 14
7878
| `-- sled
7979
| |-- blobs
8080
| |-- conf

tests/proxy/clone_sha.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"real_repo.git" = [':/sub1']
7373
.
7474
|-- josh
75-
| `-- 13
75+
| `-- 14
7676
| `-- sled
7777
| |-- blobs
7878
| |-- conf

tests/proxy/clone_subsubtree.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
]
8686
.
8787
|-- josh
88-
| `-- 13
88+
| `-- 14
8989
| `-- sled
9090
| |-- blobs
9191
| |-- conf

tests/proxy/clone_subtree.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
]
8585
.
8686
|-- josh
87-
| `-- 13
87+
| `-- 14
8888
| `-- sled
8989
| |-- blobs
9090
| |-- conf

tests/proxy/clone_subtree_no_master.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"real_repo.git" = [':/sub1']
7979
.
8080
|-- josh
81-
| `-- 13
81+
| `-- 14
8282
| `-- sled
8383
| |-- blobs
8484
| |-- conf

tests/proxy/clone_subtree_tags.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
]
115115
.
116116
|-- josh
117-
| `-- 13
117+
| `-- 14
118118
| `-- sled
119119
| |-- blobs
120120
| |-- conf

tests/proxy/clone_with_meta.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
]
130130
.
131131
|-- josh
132-
| `-- 13
132+
| `-- 14
133133
| `-- sled
134134
| |-- blobs
135135
| |-- conf

tests/proxy/empty_commit.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ should still be included.
8383
"real_repo.git" = [':/sub1']
8484
.
8585
|-- josh
86-
| `-- 13
86+
| `-- 14
8787
| `-- sled
8888
| |-- blobs
8989
| |-- conf

tests/proxy/get_version.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$ bash ${TESTDIR}/destroy_test_env.sh
88
.
99
|-- josh
10-
| `-- 13
10+
| `-- 14
1111
| `-- sled
1212
| |-- blobs
1313
| |-- conf

tests/proxy/import_export.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ Flushed credential cache
300300
"repo2.git" = [':prefix=repo2']
301301
.
302302
|-- josh
303-
| `-- 13
303+
| `-- 14
304304
| `-- sled
305305
| |-- blobs
306306
| |-- conf

tests/proxy/join_with_merge.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"real_repo.git" = [':prefix=sub1']
6060
.
6161
|-- josh
62-
| `-- 13
62+
| `-- 14
6363
| `-- sled
6464
| |-- blobs
6565
| |-- conf

tests/proxy/markers.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
]
329329
.
330330
|-- josh
331-
| `-- 13
331+
| `-- 14
332332
| `-- sled
333333
| |-- blobs
334334
| |-- conf

tests/proxy/no_proxy.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
$ bash ${TESTDIR}/destroy_test_env.sh
3636
.
3737
|-- josh
38-
| `-- 13
38+
| `-- 14
3939
| `-- sled
4040
| |-- blobs
4141
| |-- conf

tests/proxy/push_new_branch.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Check the branch again
9494
"real_repo.git" = [':/sub']
9595
.
9696
|-- josh
97-
| `-- 13
97+
| `-- 14
9898
| `-- sled
9999
| |-- blobs
100100
| |-- conf

tests/proxy/push_prefix.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
]
5757
.
5858
|-- josh
59-
| `-- 13
59+
| `-- 14
6060
| `-- sled
6161
| |-- blobs
6262
| |-- conf

tests/proxy/push_review.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Make sure all temporary namespace got removed
8484
"real_repo.git" = [':/sub1']
8585
.
8686
|-- josh
87-
| `-- 13
87+
| `-- 14
8888
| `-- sled
8989
| |-- blobs
9090
| |-- conf

tests/proxy/push_review_already_in.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test for that.
4848
"real_repo.git" = []
4949
.
5050
|-- josh
51-
| `-- 13
51+
| `-- 14
5252
| `-- sled
5353
| |-- blobs
5454
| |-- conf

tests/proxy/push_review_nop_behind.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ This is a regression test for that problem.
5555
"real_repo.git" = []
5656
.
5757
|-- josh
58-
| `-- 13
58+
| `-- 14
5959
| `-- sled
6060
| |-- blobs
6161
| |-- conf

tests/proxy/push_review_old.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Flushed credential cache
8282
"real_repo.git" = [':/sub1']
8383
.
8484
|-- josh
85-
| `-- 13
85+
| `-- 14
8686
| `-- sled
8787
| |-- blobs
8888
| |-- conf

tests/proxy/push_review_topic.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Make sure all temporary namespace got removed
3939
"real_repo.git" = [':/sub1']
4040
.
4141
|-- josh
42-
| `-- 13
42+
| `-- 14
4343
| `-- sled
4444
| |-- blobs
4545
| |-- conf

tests/proxy/push_stacked.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Make sure all temporary namespace got removed
145145
]
146146
.
147147
|-- josh
148-
| `-- 13
148+
| `-- 14
149149
| `-- sled
150150
| |-- blobs
151151
| |-- conf

tests/proxy/push_stacked_split.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Make sure all temporary namespace got removed
7676
"real_repo.git" = [':/sub1']
7777
.
7878
|-- josh
79-
| `-- 13
79+
| `-- 14
8080
| `-- sled
8181
| |-- blobs
8282
| |-- conf

tests/proxy/push_stacked_sub.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Make sure all temporary namespace got removed
129129
"real_repo.git" = [':/sub1']
130130
.
131131
|-- josh
132-
| `-- 13
132+
| `-- 14
133133
| `-- sled
134134
| |-- blobs
135135
| |-- conf

tests/proxy/push_subdir_prefix.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
]
4949
.
5050
|-- josh
51-
| `-- 13
51+
| `-- 14
5252
| `-- sled
5353
| |-- blobs
5454
| |-- conf

tests/proxy/push_subtree.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Make sure all temporary namespace got removed
8787
"real_repo.git" = [':/sub1']
8888
.
8989
|-- josh
90-
| `-- 13
90+
| `-- 14
9191
| `-- sled
9292
| |-- blobs
9393
| |-- conf

tests/proxy/push_subtree_two_repos.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Put a double slash in the URL to see that it also works
112112
"real_repo.git" = [':/sub1']
113113
.
114114
|-- josh
115-
| `-- 13
115+
| `-- 14
116116
| `-- sled
117117
| |-- blobs
118118
| |-- conf

tests/proxy/unrelated_leak.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Flushed credential cache
132132
]
133133
.
134134
|-- josh
135-
| `-- 13
135+
| `-- 14
136136
| `-- sled
137137
| |-- blobs
138138
| |-- conf

tests/proxy/workspace.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
]
226226
.
227227
|-- josh
228-
| `-- 13
228+
| `-- 14
229229
| `-- sled
230230
| |-- blobs
231231
| |-- conf

tests/proxy/workspace_create.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ Note that ws/d/ is now present in the ws
442442
]
443443
.
444444
|-- josh
445-
| `-- 13
445+
| `-- 14
446446
| `-- sled
447447
| |-- blobs
448448
| |-- conf

tests/proxy/workspace_discover.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
]
103103
.
104104
|-- josh
105-
| `-- 13
105+
| `-- 14
106106
| `-- sled
107107
| |-- blobs
108108
| |-- conf

tests/proxy/workspace_edit_commit.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
]
182182
.
183183
|-- josh
184-
| `-- 13
184+
| `-- 14
185185
| `-- sled
186186
| |-- blobs
187187
| |-- conf

0 commit comments

Comments
 (0)