Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix :squash() for histories containing an empty orphan #1350

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion josh-core/src/cache.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use std::collections::HashMap;

const CACHE_VERSION: u64 = 20;
const CACHE_VERSION: u64 = 21;

lazy_static! {
static ref DB: std::sync::Mutex<Option<sled::Db>> = std::sync::Mutex::new(None);
Expand Down
7 changes: 6 additions & 1 deletion josh-core/src/filter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,12 @@ fn apply_to_commit2(
},
);
}
tree::empty(repo)
return Ok(Some(history::drop_commit(
commit,
vec![],
transaction,
filter,
)?));
}
}
Op::Linear => {
Expand Down
12 changes: 0 additions & 12 deletions tests/filter/squash.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@

$ josh-filter -s --squash-pattern "refs/tags/*" --update refs/heads/filtered
Warning: reference refs/heads/filtered wasn't updated
[1] :squash(

)

$ git log --graph --decorate --pretty=oneline refs/heads/filtered
fatal: ambiguous argument 'refs/heads/filtered': unknown revision or path not in the working tree.
Expand All @@ -45,9 +42,6 @@ This one tag is an annotated tag, to make sure those are handled as well
$ josh-filter -s --squash-pattern "refs/tags/*" :author=\"New\ Author\"\;\"[email protected]\" --update refs/heads/filtered
[1] :author="New Author";"[email protected]"
[1] :squash(

)
[2] :squash(
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/tags/tag_a"
)

Expand All @@ -67,9 +61,6 @@ This one tag is an annotated tag, to make sure those are handled as well

$ josh-filter -s --squash-pattern "refs/tags/*" :author=\"New\ Author\"\;\"[email protected]\" --update refs/heads/filtered
[1] :squash(

)
[2] :squash(
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/tags/tag_a"
)
[3] :squash(
Expand Down Expand Up @@ -124,9 +115,6 @@ This one tag is an annotated tag, to make sure those are handled as well
):author="New Author";"[email protected]"
$ josh-filter -s --file filter.josh --update refs/heads/filtered
[1] :squash(

)
[2] :squash(
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/tags/tag_a"
)
[3] :squash(
Expand Down
54 changes: 54 additions & 0 deletions tests/filter/squash_empty_initial.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
$ export RUST_BACKTRACE=1
$ git init -q 1> /dev/null

$ git commit -m "Empty initial" --allow-empty 1> /dev/null

$ git log --graph --pretty=%s
* Empty initial

$ git checkout -b branch2
Switched to a new branch 'branch2'

$ echo contents2 > file1
$ git add .
$ git commit -m "mod file1" 1> /dev/null

$ echo contents3 > file3
$ git add .
$ git commit -m "mod file3" 1> /dev/null

$ git checkout master
Switched to branch 'master'

$ echo contents3 > file2
$ git add .
$ git commit -m "add file2" 1> /dev/null

$ git merge -q branch2 --no-ff

$ git log --graph --decorate --pretty=oneline
* 882f2656a5075936eb37bfefde740e0b453e4479 (HEAD -> master) Merge branch 'branch2'
|\
| * 87bb87b63d1745136cb2ea167ef3ffc82c7ef3f0 (branch2) mod file3
| * 2db14eafe99deeeab5db07bf33e332d523a298ab mod file1
* | 54d8f704681c3b44a468cef655fa3b5bc5229a4c add file2
|/
* 8c26fa0172bda17bafcbcf9684e639c6b0bae9c4 Empty initial

$ josh-filter -s --squash-pattern "refs/tags/*" --update refs/heads/filtered
Warning: reference refs/heads/filtered wasn't updated
$ git log --graph --decorate --pretty=oneline refs/heads/filtered
fatal: ambiguous argument 'refs/heads/filtered': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
[128]

$ git tag -a tag_a -m "created a tag" 882f2656a5075936eb37bfefde740e0b453e4479
$ josh-filter -s --squash-pattern "refs/tags/*" :author=\"New\ Author\"\;\"new@e.mail\" --update refs/heads/filtered
[1] :author="New Author";"new@e.mail"
[1] :squash(
882f2656a5075936eb37bfefde740e0b453e4479:"refs/tags/tag_a"
)
$ git log --graph --decorate --pretty=oneline refs/heads/filtered
* d8aa5a9937f4f0bd645dbc0b591bae5cd6b6d91b (tag: filtered/tag_a, filtered) refs/tags/tag_a
2 changes: 1 addition & 1 deletion tests/proxy/amend_patchset.t
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/authentication.t
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"real_repo.git" = ["::sub1/"]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
4 changes: 2 additions & 2 deletions tests/proxy/caching.t
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down Expand Up @@ -162,7 +162,7 @@
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_absent_head.t
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
$ bash ${TESTDIR}/destroy_test_env.sh
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_all.t
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"real_repo.git" = ["::sub1/"]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_blocked.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
$ bash ${TESTDIR}/destroy_test_env.sh
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_invalid_url.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
$ bash ${TESTDIR}/destroy_test_env.sh
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_locked_refs.t
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_prefix.t
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_sha.t
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Check (2) and (3) but with a branch ref
"real_repo.git" = ["::sub1/"]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_subsubtree.t
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_subtree.t
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_subtree_no_master.t
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"real_repo.git" = [":/sub1"]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_subtree_tags.t
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/clone_with_meta.t
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/empty_commit.t
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ should still be included.
"real_repo.git" = ["::sub1/"]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/get_version.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$ bash ${TESTDIR}/destroy_test_env.sh
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/import_export.t
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ Flushed credential cache
"repo2.git" = [":prefix=repo2"]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/join_subtree.t
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Make sure all temporary namespace got removed
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/join_with_merge.t
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"real_repo.git" = [":prefix=sub1"]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/markers.t
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/no_proxy.t
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$ bash ${TESTDIR}/destroy_test_env.sh
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/no_proxy_lfs.t
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
$ bash ${TESTDIR}/destroy_test_env.sh
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/push_graphql.t
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"real_repo.git" = ["::sub1/"]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/push_new_branch.t
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Check the branch again
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/push_prefix.t
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/push_review.t
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Make sure all temporary namespace got removed
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/push_review_already_in.t
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test for that.
"real_repo.git" = []
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/push_review_nop_behind.t
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This is a regression test for that problem.
"real_repo.git" = []
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/push_review_old.t
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Flushed credential cache
]
.
|-- josh
| `-- 20
| `-- 21
| `-- sled
| |-- blobs
| |-- conf
Expand Down
Loading
Loading