Skip to content

Commit

Permalink
Fix workspace redirect
Browse files Browse the repository at this point in the history
Change: fix-redirect
  • Loading branch information
christian-schilling committed Nov 14, 2023
1 parent d8af95d commit 91e8b5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion josh-core/src/filter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,12 @@ fn apply_to_commit2(
.collect::<Option<Vec<git2::Oid>>>();

if let Some(redirect) = resolve_workspace_redirect(repo, &commit.tree()?, ws_path) {
return apply_to_commit2(&to_op(redirect), &commit, transaction);
if let Some(r) = apply_to_commit2(&to_op(redirect), &commit, transaction)? {
transaction.insert(filter, commit.id(), r, true);
return Ok(Some(r));
} else {
return Ok(None);
}
}

let normal_parents = some_or!(normal_parents, { return Ok(None) });
Expand Down Expand Up @@ -758,6 +763,11 @@ fn apply2<'a>(
let wsj_file = to_filter(Op::File(Path::new("workspace.josh").to_owned()));
let base = to_filter(Op::Subdir(path.to_owned()));
let wsj_file = chain(base, wsj_file);

if let Some(redirect) = resolve_workspace_redirect(repo, &tree, path) {
return apply(transaction, redirect, tree);
}

apply(
transaction,
compose(wsj_file, compose(get_workspace(repo, &tree, path), base)),
Expand Down
4 changes: 3 additions & 1 deletion tests/filter/workspace_redirect.t
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
]
[2] :workspace=ws
$ josh-filter -s :workspace=ws_new master --update refs/heads/filtered_new
[1] :workspace=ws_new
[2] :[
a = :/sub1
::sub2/subsub/
Expand Down Expand Up @@ -142,6 +143,7 @@
a = :/sub1
::sub2/subsub/
]
[2] :workspace=ws
[2] :workspace=ws_new
[3] :exclude[::ws]
[3] :exclude[::ws_new]
[3] :workspace=ws

0 comments on commit 91e8b5d

Please sign in to comment.