Skip to content

Commit 9ad455b

Browse files
Fix off-by-one error in :prune filter (#1522)
As the docs say this should only apply to merge commits. Unfortunately this means we have to bump CACHE_VERSION in case someone has already used this. Change: fix-prune
1 parent 68709d4 commit 9ad455b

Some content is hidden

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

54 files changed

+66
-57
lines changed

josh-core/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 = 22;
4+
const CACHE_VERSION: u64 = 23;
55

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

josh-core/src/filter/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ fn apply_to_commit2(
816816
Op::Prune => {
817817
let p: Vec<_> = commit.parent_ids().collect();
818818

819-
if p.len() > 0 {
819+
if p.len() > 1 {
820820
let parent = some_or!(transaction.get(filter, p[0]), {
821821
return Ok(None);
822822
});

tests/filter/prune_trivial_merge.t

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,36 @@
2121
$ git add .
2222
$ git commit -m "mod file1" 1> /dev/null
2323

24+
$ git commit --allow-empty -m "empty commit" 1> /dev/null
25+
2426
$ git merge -q branch1 --no-ff
2527
$ git log --graph --pretty=%s
2628
* Merge branch 'branch1'
2729
|\
2830
| * add file2
31+
* | empty commit
2932
* | mod file1
3033
|/
3134
* add file1
3235

3336
$ josh-filter -s ::file1
34-
[3] ::file1
37+
[4] ::file1
3538
$ git log --graph --pretty=%s FILTERED_HEAD
3639
* Merge branch 'branch1'
3740
|\
41+
* | empty commit
3842
* | mod file1
3943
|/
4044
* add file1
4145
$ josh-filter -s ::file1:prune=trivial-merge
42-
[2] :prune=trivial-merge
43-
[3] ::file1
46+
[3] :prune=trivial-merge
47+
[4] ::file1
4448

4549
$ git log --graph --pretty=%s FILTERED_HEAD
50+
* empty commit
4651
* mod file1
4752
* add file1
53+
54+
55+
56+

tests/proxy/amend_patchset.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
]
125125
.
126126
|-- josh
127-
| `-- 22
127+
| `-- 23
128128
| `-- sled
129129
| |-- blobs
130130
| |-- 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-
| `-- 22
127+
| `-- 23
128128
| `-- sled
129129
| |-- blobs
130130
| |-- conf

tests/proxy/caching.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
]
5252
.
5353
|-- josh
54-
| `-- 22
54+
| `-- 23
5555
| `-- sled
5656
| |-- blobs
5757
| |-- conf
@@ -162,7 +162,7 @@
162162
]
163163
.
164164
|-- josh
165-
| `-- 22
165+
| `-- 23
166166
| `-- sled
167167
| |-- blobs
168168
| |-- conf

tests/proxy/clone_absent_head.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
$ bash ${TESTDIR}/destroy_test_env.sh
8686
.
8787
|-- josh
88-
| `-- 22
88+
| `-- 23
8989
| `-- sled
9090
| |-- blobs
9191
| |-- 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-
| `-- 22
56+
| `-- 23
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-
| `-- 22
12+
| `-- 23
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-
| `-- 22
35+
| `-- 23
3636
| `-- sled
3737
| |-- blobs
3838
| |-- conf

0 commit comments

Comments
 (0)