From db9484834116809ca8b85f776378b62e75b5c3fc Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 28 Mar 2024 23:14:01 +0900 Subject: [PATCH] sparse: deduplicate edited patterns Since "set --add" removes duplicated patterns, it makes sense for "edit" to do the same thing. --- cli/src/commands/sparse.rs | 1 + cli/tests/test_sparse_command.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/src/commands/sparse.rs b/cli/src/commands/sparse.rs index 4a2e10784..01a4433da 100644 --- a/cli/src/commands/sparse.rs +++ b/cli/src/commands/sparse.rs @@ -145,6 +145,7 @@ fn cmd_sparse_edit( update_sparse_patterns_with(ui, &mut workspace_command, |_ui, old_patterns| { let mut new_patterns = edit_sparse(&repo_path, old_patterns, command.settings())?; new_patterns.sort_unstable(); + new_patterns.dedup(); Ok(new_patterns) }) } diff --git a/cli/tests/test_sparse_command.rs b/cli/tests/test_sparse_command.rs index c62f65007..6ad47880b 100644 --- a/cli/tests/test_sparse_command.rs +++ b/cli/tests/test_sparse_command.rs @@ -159,7 +159,7 @@ fn test_sparse_manage_patterns() { "###); // Can edit with multiple files - edit_patterns(&["file3", "file2"]); + edit_patterns(&["file3", "file2", "file3"]); let (stdout, stderr) = test_env.jj_cmd_ok(&sub_dir, &["sparse", "edit"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###"