Skip to content

Commit af42cf4

Browse files
Fix workspace redirect (#1297)
Change: fix-redirect
1 parent d8af95d commit af42cf4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

josh-core/src/filter/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,12 @@ fn apply_to_commit2(
571571
.collect::<Option<Vec<git2::Oid>>>();
572572

573573
if let Some(redirect) = resolve_workspace_redirect(repo, &commit.tree()?, ws_path) {
574-
return apply_to_commit2(&to_op(redirect), &commit, transaction);
574+
if let Some(r) = apply_to_commit2(&to_op(redirect), &commit, transaction)? {
575+
transaction.insert(filter, commit.id(), r, true);
576+
return Ok(Some(r));
577+
} else {
578+
return Ok(None);
579+
}
575580
}
576581

577582
let normal_parents = some_or!(normal_parents, { return Ok(None) });
@@ -758,6 +763,11 @@ fn apply2<'a>(
758763
let wsj_file = to_filter(Op::File(Path::new("workspace.josh").to_owned()));
759764
let base = to_filter(Op::Subdir(path.to_owned()));
760765
let wsj_file = chain(base, wsj_file);
766+
767+
if let Some(redirect) = resolve_workspace_redirect(repo, &tree, path) {
768+
return apply(transaction, redirect, tree);
769+
}
770+
761771
apply(
762772
transaction,
763773
compose(wsj_file, compose(get_workspace(repo, &tree, path), base)),

tests/filter/workspace_redirect.t

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
]
4040
[2] :workspace=ws
4141
$ josh-filter -s :workspace=ws_new master --update refs/heads/filtered_new
42+
[1] :workspace=ws_new
4243
[2] :[
4344
a = :/sub1
4445
::sub2/subsub/
@@ -142,6 +143,7 @@
142143
a = :/sub1
143144
::sub2/subsub/
144145
]
145-
[2] :workspace=ws
146+
[2] :workspace=ws_new
146147
[3] :exclude[::ws]
147148
[3] :exclude[::ws_new]
149+
[3] :workspace=ws

0 commit comments

Comments
 (0)