Skip to content

Commit db4ab99

Browse files
authored
Revert "Fix exclude of compose" (#519)
The behaviour was correct. The documentation needs to be updated: Exclude removes the result of applying the exluded filter This reverts commit 6d7a538.
1 parent 6d7a538 commit db4ab99

File tree

9 files changed

+65
-170
lines changed

9 files changed

+65
-170
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 VERSION: u64 = 7;
4+
const VERSION: u64 = 6;
55

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

src/filter/mod.rs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -377,23 +377,18 @@ fn apply_to_commit2(
377377
.map(|x| x.tree_id())
378378
.unwrap_or(tree::empty_id())
379379
};
380-
let bu = {
380+
let bf = {
381381
transaction
382382
.repo()
383383
.find_commit(some_or!(
384-
apply_to_commit2(
385-
&Op::Chain(
386-
to_filter(Op::Paths),
387-
to_filter(Op::Chain(*b, to_filter(Op::Invert))),
388-
),
389-
commit,
390-
transaction,
391-
)?,
384+
apply_to_commit2(&to_op(*b), commit, transaction)?,
392385
{ return Ok(None) }
393386
))
394-
.map(|x| x.tree())
395-
.unwrap_or(Ok(tree::empty(repo)))
396-
}?;
387+
.map(|x| x.tree_id())
388+
.unwrap_or(tree::empty_id())
389+
};
390+
let bf = repo.find_tree(bf)?;
391+
let bu = unapply(transaction, *b, bf, tree::empty(repo))?;
397392
let ba = apply(transaction, *a, bu)?;
398393

399394
repo.find_tree(tree::subtract(repo, af, ba.id())?)?
@@ -479,14 +474,8 @@ fn apply2<'a>(
479474

480475
Op::Subtract(a, b) => {
481476
let af = apply(transaction, *a, tree.clone())?;
482-
let bu = apply(
483-
transaction,
484-
to_filter(Op::Chain(
485-
to_filter(Op::Paths),
486-
to_filter(Op::Chain(*b, to_filter(Op::Invert))),
487-
)),
488-
tree.clone(),
489-
)?;
477+
let bf = apply(transaction, *b, tree.clone())?;
478+
let bu = unapply(transaction, *b, bf, tree::empty(repo))?;
490479
let ba = apply(transaction, *a, bu)?;
491480
Ok(repo.find_tree(tree::subtract(repo, af.id(), ba.id())?)?)
492481
}

tests/filter/empty_orphan.t

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,9 @@ Empty root commits from unrelated parts of the tree should not be included
101101
c/file3
102102

103103
$ josh-filter -s c=:exclude[:/sub1] master
104-
[4] :INVERT
105-
[4] _invert
104+
[5] :/sub1
106105
[5] :exclude[:/sub1]
107106
[6] :prefix=c
108-
[7] :PATHS
109-
[9] :/sub1
110-
[10] _paths
111107

112108
$ git log FILTERED_HEAD --graph --pretty=%s
113109
* add some_other_file
@@ -120,13 +116,9 @@ Empty root commits from unrelated parts of the tree should not be included
120116

121117
$ josh-filter -s :prefix=x FILTERED_HEAD
122118
[3] :prefix=x
123-
[4] :INVERT
124-
[4] _invert
119+
[5] :/sub1
125120
[5] :exclude[:/sub1]
126121
[6] :prefix=c
127-
[7] :PATHS
128-
[9] :/sub1
129-
[10] _paths
130122

131123
$ git ls-tree --name-only -r FILTERED_HEAD
132124
x/c/some_file

tests/filter/exclude_compose.t

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -14,53 +14,37 @@
1414
$ git add sub2
1515
$ git commit -m "add file2" 1> /dev/null
1616

17-
$ mkdir sub3
18-
$ echo contents1 > sub3/file3
19-
$ git add sub3
20-
$ git commit -m "add file3" 1> /dev/null
21-
22-
$ echo contents1 > file4
23-
$ git add file4
24-
$ git commit -m "add file4" 1> /dev/null
25-
2617
$ josh-filter -s :exclude[:/sub2] master --update refs/heads/hidden
27-
[1] :INVERT
28-
[1] _invert
18+
[1] :exclude[:/sub2]
2919
[2] :/sub2
30-
[3] :exclude[:/sub2]
31-
[4] :PATHS
32-
[7] _paths
3320
$ git checkout hidden 1> /dev/null
3421
Switched to branch 'hidden'
3522
$ tree
3623
.
37-
|-- file4
38-
|-- sub1
39-
| `-- file1
40-
`-- sub3
41-
`-- file3
24+
`-- sub1
25+
`-- file1
4226

43-
2 directories, 3 files
27+
1 directory, 1 file
4428
$ git log --graph --pretty=%s
45-
* add file4
46-
* add file3
4729
* add file1
4830

4931
$ echo contents3 > sub1/file3
5032
$ git add sub1/file3
5133
$ git commit -m "add sub1/file3" 1> /dev/null
5234

53-
$ josh-filter -s :exclude[:/sub1]:exclude[:/sub2]:exclude[:/sub3] master --update refs/josh/filtered
35+
$ josh-filter -s :exclude[:/sub1,:/sub2] master --update refs/josh/filtered
5436
[1] :/sub1
55-
[1] :/sub3
56-
[2] :exclude[:/sub3]
57-
[3] :/sub2
58-
[3] :INVERT
59-
[3] _invert
60-
[4] :exclude[:/sub1]
61-
[6] :exclude[:/sub2]
62-
[9] :PATHS
63-
[12] _paths
37+
[1] :exclude[
38+
:/sub1
39+
:/sub2
40+
]
41+
[1] :exclude[:/sub2]
42+
[2] :/sub2
43+
[2] :[
44+
:/sub1
45+
:/sub2
46+
]
47+
6448
$ git checkout refs/josh/filtered
6549
Note: switching to 'refs/josh/filtered'.
6650

@@ -79,38 +63,10 @@
7963

8064
Turn off this advice by setting config variable advice.detachedHead to false
8165

82-
HEAD is now at e96b01b add file4
83-
$ tree
84-
.
85-
`-- file4
86-
87-
0 directories, 1 file
88-
$ josh-filter -s :exclude[:/sub1,:/sub2,:/sub3] master --update refs/josh/filtered
89-
[1] :/sub1
90-
[2] :exclude[
91-
:/sub1
92-
:/sub2
93-
:/sub3
94-
]
95-
[2] :exclude[:/sub3]
96-
[3] :/sub2
97-
[3] :/sub3
98-
[3] :[
99-
:/sub1
100-
:/sub2
101-
:/sub3
102-
]
103-
[4] :exclude[:/sub1]
104-
[5] :INVERT
105-
[5] _invert
106-
[6] :exclude[:/sub2]
107-
[9] :PATHS
108-
[12] _paths
109-
110-
$ git checkout refs/josh/filtered
111-
HEAD is now at e96b01b add file4
66+
HEAD is now at bb282e9 add file1
11267
$ tree
11368
.
114-
`-- file4
69+
`-- sub1
70+
`-- file1
11571

116-
0 directories, 1 file
72+
1 directory, 1 file

tests/filter/hide_view.t

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@
3636
$ josh-filter -s c=:exclude[:/sub1] master --update refs/josh/filter/master
3737
[1] :prefix=c
3838
[2] :/sub1
39-
[2] :INVERT
4039
[2] :exclude[:/sub1]
41-
[2] _invert
42-
[3] :PATHS
43-
[6] _paths
4440
$ git checkout josh/filter/master 2> /dev/null
4541
$ git log --graph --pretty=%s
4642
* add file3
@@ -57,11 +53,7 @@
5753
[2] ::sub1/file2
5854
[2] :exclude[:/sub1]
5955
[2] :exclude[::sub1/file2]
60-
[3] :INVERT
61-
[3] :PATHS
6256
[3] :prefix=c
63-
[4] _invert
64-
[6] _paths
6557
$ git checkout josh/filter/master 2> /dev/null
6658
$ git log --graph --pretty=%s
6759
* add file3
@@ -83,11 +75,7 @@
8375
[2] :exclude[:/sub1]
8476
[2] :exclude[::sub1/file2]
8577
[2] :exclude[::sub2/file3]
86-
[3] :PATHS
87-
[4] :INVERT
8878
[4] :prefix=c
89-
[6] _invert
90-
[6] _paths
9179
$ git checkout josh/filter/master 2> /dev/null
9280
$ git log --graph --pretty=%s
9381
* add file2

tests/filter/permissions.t

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,9 @@
185185
[1] :/a
186186
[1] :exclude[:/c]
187187
[1] :prefix=x
188-
[3] :INVERT
189-
[6] :/c
190-
[6] :PATHS
191-
[7] _invert
192-
[28] _paths
188+
[3] :/c
189+
[3] :PATHS
190+
[16] _paths
193191

194192
$ git log --graph --pretty=%s refs/josh/filtered
195193
* add dirs
@@ -237,11 +235,11 @@
237235
[1] :/a
238236
[1] :exclude[:/c]
239237
[1] :prefix=x
240-
[6] :/c
241-
[6] :INVERT
242-
[6] :PATHS
243-
[19] _invert
244-
[28] _paths
238+
[3] :/c
239+
[3] :INVERT
240+
[3] :PATHS
241+
[12] _invert
242+
[16] _paths
245243

246244
$ git checkout refs/josh/filtered 2> /dev/null
247245
$ tree
@@ -315,12 +313,12 @@
315313
[1] :/a
316314
[1] :exclude[:/c]
317315
[1] :prefix=x
316+
[3] :/c
317+
[3] :PATHS
318318
[3] :workspace=a
319-
[6] :/c
320-
[6] :PATHS
321-
[9] :INVERT
322-
[28] _paths
323-
[29] _invert
319+
[6] :INVERT
320+
[16] _paths
321+
[22] _invert
324322

325323
$ git checkout refs/josh/filtered 2> /dev/null
326324
$ tree
@@ -383,13 +381,13 @@
383381
[1] :/a
384382
[1] :exclude[:/c]
385383
[1] :prefix=x
384+
[3] :/c
386385
[3] :FOLD
386+
[3] :PATHS
387387
[3] :workspace=a
388-
[6] :/c
389-
[6] :PATHS
390-
[9] :INVERT
391-
[28] _paths
392-
[29] _invert
388+
[6] :INVERT
389+
[16] _paths
390+
[22] _invert
393391

394392

395393

@@ -408,13 +406,13 @@
408406
[1] :/a
409407
[1] :exclude[:/c]
410408
[1] :prefix=x
409+
[3] :/c
411410
[3] :FOLD
412411
[3] :workspace=a
413-
[6] :/c
414-
[8] :PATHS
415-
[9] :INVERT
416-
[29] _invert
417-
[31] _paths
412+
[5] :PATHS
413+
[6] :INVERT
414+
[19] _paths
415+
[22] _invert
418416

419417
$ git log --graph --pretty=%s master
420418
* add newfile
@@ -538,12 +536,12 @@
538536
[1] :exclude[:/c]
539537
[1] :prefix=x
540538
[3] :workspace=a
539+
[4] :/c
540+
[5] :PATHS
541541
[6] :FOLD
542-
[7] :/c
543-
[8] :PATHS
544-
[9] :INVERT
545-
[29] _invert
546-
[31] _paths
542+
[6] :INVERT
543+
[19] _paths
544+
[22] _invert
547545

548546
$ git log --graph --pretty=%s refs/josh/filtered
549547
* add file_cd3
@@ -593,13 +591,13 @@
593591
[1] :/a
594592
[1] :exclude[:/c]
595593
[1] :prefix=x
594+
[4] :/c
595+
[5] :PATHS
596596
[5] :workspace=a
597-
[7] :/c
598-
[8] :PATHS
599-
[9] :INVERT
597+
[6] :INVERT
600598
[10] :FOLD
601-
[29] _invert
602-
[31] _paths
599+
[19] _paths
600+
[22] _invert
603601

604602
$ git log --graph --pretty=%s refs/josh/filtered
605603
* add newfile

tests/filter/reverse_hide.t

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@
1515
$ git commit -m "add file2" 1> /dev/null
1616

1717
$ josh-filter -s :exclude[:/sub2] master --update refs/heads/hidden
18-
[1] :INVERT
1918
[1] :exclude[:/sub2]
20-
[1] _invert
2119
[2] :/sub2
22-
[2] :PATHS
23-
[4] _paths
2420
$ git checkout hidden 1> /dev/null
2521
Switched to branch 'hidden'
2622
$ tree
@@ -37,12 +33,8 @@
3733
$ git commit -m "add sub1/file3" 1> /dev/null
3834

3935
$ josh-filter -s :exclude[:/sub2] --reverse master --update refs/heads/hidden
40-
[1] :INVERT
4136
[1] :exclude[:/sub2]
42-
[1] _invert
4337
[2] :/sub2
44-
[2] :PATHS
45-
[4] _paths
4638

4739
$ git checkout master
4840
Switched to branch 'master'

0 commit comments

Comments
 (0)