-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workspace: don't lose sparsed-away paths when recovering workspace
When an operation is missing and we recover the workspace, we create a new working-copy commit on top of the desired working-copy commit (per the available head operation). We then reset the working copy to an empty tree because it shouldn't really matter much which commit we reset to. However, when the workspace is sparse, it does matter, as the test case from the previous patch shows. This patch fixes it by replacing the `reset_to_empty()` method by a new `recover(&Commit)`, which effectively resets to the empty tree and then resets to the commit. That way, any subsequent snapshotting will result keep the paths from that tree for paths outside the sparse patterns.
- Loading branch information
1 parent
ffb1268
commit c55e080
Showing
5 changed files
with
15 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -494,7 +494,7 @@ fn test_workspaces_current_op_discarded_by_other() { | |
insta::assert_snapshot!(stdout, @""); | ||
|
||
insta::assert_snapshot!(get_log_output(&test_env, &main_path), @r###" | ||
◉ 8fd911b4e595 secondary@ | ||
◉ b93a924213f3 secondary@ | ||
◉ ec4904a30161 | ||
│ @ 74769415363f default@ | ||
├─╯ | ||
|
@@ -511,14 +511,12 @@ fn test_workspaces_current_op_discarded_by_other() { | |
"###); | ||
let (stdout, stderr) = test_env.jj_cmd_ok(&secondary_path, &["st"]); | ||
insta::assert_snapshot!(stderr, @""); | ||
// TODO: The file outside the sparse patterns should still be there | ||
insta::assert_snapshot!(stdout, @r###" | ||
Working copy changes: | ||
A added | ||
D deleted | ||
M modified | ||
D sparse | ||
Working copy : kmkuslsw 8fd911b4 (no description set) | ||
Working copy : kmkuslsw b93a9242 (no description set) | ||
Parent commit: rzvqmyuk ec4904a3 (empty) (no description set) | ||
"###); | ||
// The modified file should have the same contents it had before (not reset to | ||
|
@@ -530,7 +528,7 @@ fn test_workspaces_current_op_discarded_by_other() { | |
let (stdout, stderr) = test_env.jj_cmd_ok(&secondary_path, &["obslog"]); | ||
insta::assert_snapshot!(stderr, @""); | ||
insta::assert_snapshot!(stdout, @r###" | ||
@ kmkuslsw [email protected] 2001-02-03 04:05:18.000 +07:00 secondary@ 8fd911b4 | ||
@ kmkuslsw [email protected] 2001-02-03 04:05:18.000 +07:00 secondary@ b93a9242 | ||
│ (no description set) | ||
◉ kmkuslsw hidden [email protected] 2001-02-03 04:05:18.000 +07:00 30ee0d1f | ||
(empty) (no description set) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters