@@ -56,6 +56,30 @@ fn test_rewrite_immutable_generic() {
5656 insta:: assert_snapshot!( stderr, @r###"
5757 Error: The root commit 000000000000 is immutable
5858 "### ) ;
59+
60+ // Error mutating the repo if immutable_heads() uses a ref that can't be
61+ // resolved
62+ test_env. add_config ( r#"revset-aliases."immutable_heads()" = "branch_that_does_not_exist""# ) ;
63+ let stderr = test_env. jj_cmd_failure ( & repo_path, & [ "new" , "main" ] ) ;
64+ insta:: assert_snapshot!( stderr, @r###"
65+ Config error: Invalid `revset-aliases.immutable_heads()`
66+ Caused by: Revision "branch_that_does_not_exist" doesn't exist
67+ For help, see https://github.com/martinvonz/jj/blob/main/docs/config.md.
68+ "### ) ;
69+
70+ // Mutating the repo works if ref is wrapped in present()
71+ test_env. add_config (
72+ r#"revset-aliases."immutable_heads()" = "present(branch_that_does_not_exist)""# ,
73+ ) ;
74+ let ( stdout, stderr) = test_env. jj_cmd_ok ( & repo_path, & [ "new" , "main" ] ) ;
75+ insta:: assert_snapshot!( stdout, @r###"
76+ "### ) ;
77+ insta:: assert_snapshot!( stderr, @r###"
78+ Working copy now at: kpqxywon dbce15b4 (empty) (no description set)
79+ Parent commit : kkmpptxz c8d4c7ca main | b
80+ Added 0 files, modified 1 files, removed 0 files
81+ "### ) ;
82+
5983 // Error if we redefine immutable_heads() with an argument
6084 test_env. add_config ( r#"revset-aliases."immutable_heads(foo)" = "none()""# ) ;
6185 let stderr = test_env. jj_cmd_failure ( & repo_path, & [ "edit" , "root()" ] ) ;
0 commit comments