Skip to content

Commit

Permalink
git_backend: add a README to conflicted commits
Browse files Browse the repository at this point in the history
When you use e.g. `git switch` to check out a conflicted commit,
you're going to end up with the `.jjconflicts-*` directories in your
working copy. It's probably not obvious what those mean. This patch
adds a README file to the root tree to try to explain to users what's
going on and how to recover.

The authoritative information about conflicts is stored in the
`jj:trees` commit header. The contents of conflicted commits is only
used for preventing GC. We can therefore add contents to the tree
without much consequence.
  • Loading branch information
martinvonz committed Apr 22, 2024
1 parent e14ee8b commit 2f4a553
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 88 deletions.
6 changes: 3 additions & 3 deletions cli/tests/test_chmod_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn test_chmod_regular_conflict() {
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["chmod", "x", "nonexistent", "file"]);
insta::assert_snapshot!(stderr, @r###"
Warning: No matching entries for paths: nonexistent
Working copy now at: yostqsxw cbc43289 conflict | (conflict) conflict
Working copy now at: yostqsxw e5912d62 conflict | (conflict) conflict
Parent commit : royxmykx 427fbd2f x | x
Parent commit : zsuskuln 3f83a26d n | n
Added 0 files, modified 1 files, removed 0 files
Expand Down Expand Up @@ -213,13 +213,13 @@ fn test_chmod_file_dir_deletion_conflicts() {
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
New conflicts appeared in these commits:
kmkuslsw b4c38719 file_deletion | (conflict) file_deletion
kmkuslsw 1b2ef84c file_deletion | (conflict) file_deletion
To resolve the conflicts, start by updating to it:
jj new kmkuslswpqwq
Then use `jj resolve`, or edit the conflict markers in the file directly.
Once the conflicts are resolved, you may want inspect the result with `jj diff`.
Then run `jj squash` to move the resolution into the conflicted commit.
Working copy now at: kmkuslsw b4c38719 file_deletion | (conflict) file_deletion
Working copy now at: kmkuslsw 1b2ef84c file_deletion | (conflict) file_deletion
Parent commit : zsuskuln c51c9c55 file | file
Parent commit : royxmykx 6b18b3c1 deletion | deletion
Added 0 files, modified 1 files, removed 0 files
Expand Down
6 changes: 3 additions & 3 deletions cli/tests/test_diffedit_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,10 @@ fn test_diffedit_merge() {
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["diffedit", "-r", "@-"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Created royxmykx b90654a0 (conflict) merge
Created royxmykx b9539d6e (conflict) merge
Rebased 1 descendant commits
Working copy now at: yqosqzyt 1de824f2 (conflict) (empty) (no description set)
Parent commit : royxmykx b90654a0 (conflict) merge
Working copy now at: yqosqzyt 0a24ed24 (conflict) (empty) (no description set)
Parent commit : royxmykx b9539d6e (conflict) merge
Added 0 files, modified 0 files, removed 1 files
There are unresolved conflicts at these paths:
file2 2-sided conflict
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_git_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ fn test_git_push_conflict() {
test_env.jj_cmd_ok(&workspace_root, &["describe", "-m", "third"]);
let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "push", "--all"]);
insta::assert_snapshot!(stderr, @r###"
Error: Won't push commit d9ca3146ade7 since it has conflicts
Error: Won't push commit 739c4f08a056 since it has conflicts
"###);
}

Expand Down
36 changes: 18 additions & 18 deletions cli/tests/test_immutable_commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn test_rewrite_immutable_commands() {
insta::assert_snapshot!(stdout, @r###"
@ yqosqzyt [email protected] 2001-02-03 08:05:13 3f89addf
│ (empty) (no description set)
│ ◉ mzvwutvl [email protected] 2001-02-03 08:05:11 main 3d14df18 conflict
│ ◉ mzvwutvl [email protected] 2001-02-03 08:05:11 main 406c181c conflict
╭─┤ (empty) merge
│ │
│ ~
Expand All @@ -129,71 +129,71 @@ fn test_rewrite_immutable_commands() {
// abandon
let stderr = test_env.jj_cmd_failure(&repo_path, &["abandon", "main"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// chmod
let stderr = test_env.jj_cmd_failure(&repo_path, &["chmod", "-r=main", "x", "file"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// describe
let stderr = test_env.jj_cmd_failure(&repo_path, &["describe", "main"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// diffedit
let stderr = test_env.jj_cmd_failure(&repo_path, &["diffedit", "-r=main"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// edit
let stderr = test_env.jj_cmd_failure(&repo_path, &["edit", "main"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// move --from
let stderr = test_env.jj_cmd_failure(&repo_path, &["move", "--from=main"]);
insta::assert_snapshot!(stderr, @r###"
Warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent
Warning: `jj move` will be removed in a future version, and this will be a hard error
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// move --to
let stderr = test_env.jj_cmd_failure(&repo_path, &["move", "--to=main"]);
insta::assert_snapshot!(stderr, @r###"
Warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent
Warning: `jj move` will be removed in a future version, and this will be a hard error
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// new --insert-before
let stderr = test_env.jj_cmd_failure(&repo_path, &["new", "--insert-before", "main"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// new --insert-after parent_of_main
let stderr = test_env.jj_cmd_failure(&repo_path, &["new", "--insert-after", "description(b)"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// parallelize
let stderr = test_env.jj_cmd_failure(&repo_path, &["parallelize", "description(b)", "main"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// rebase -s
let stderr = test_env.jj_cmd_failure(&repo_path, &["rebase", "-s=main", "-d=@"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// rebase -b
Expand All @@ -205,31 +205,31 @@ fn test_rewrite_immutable_commands() {
// rebase -r
let stderr = test_env.jj_cmd_failure(&repo_path, &["rebase", "-r=main", "-d=@"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// resolve
let stderr = test_env.jj_cmd_failure(&repo_path, &["resolve", "-r=description(merge)", "file"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// restore -c
let stderr = test_env.jj_cmd_failure(&repo_path, &["restore", "-c=main"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// restore --to
let stderr = test_env.jj_cmd_failure(&repo_path, &["restore", "--to=main"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// split
let stderr = test_env.jj_cmd_failure(&repo_path, &["split", "-r=main"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
// squash
Expand All @@ -241,7 +241,7 @@ fn test_rewrite_immutable_commands() {
// unsquash
let stderr = test_env.jj_cmd_failure(&repo_path, &["unsquash", "-r=main"]);
insta::assert_snapshot!(stderr, @r###"
Error: Commit 3d14df18607e is immutable
Error: Commit 406c181c04d8 is immutable
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
"###);
}
16 changes: 8 additions & 8 deletions cli/tests/test_obslog_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn test_obslog_with_or_without_diff() {
insta::assert_snapshot!(stdout, @r###"
@ rlvkpnrz [email protected] 2001-02-03 08:05:10 66b42ad3
│ my description
◉ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 ebc23d4b conflict
◉ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 cf73917d conflict
│ my description
◉ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 6fbba7bc
│ my description
Expand All @@ -44,11 +44,11 @@ fn test_obslog_with_or_without_diff() {
insta::assert_snapshot!(stdout, @r###"
@ rlvkpnrz [38;5;[email protected] 2001-02-03 08:05:10 66b42ad3
│ my description
◉ [1m[39mr[0m[38;5;8mlvkpnrz[39m hidden [38;5;[email protected][39m [38;5;6m2001-02-03 08:05:09[39m [1m[38;5;4meb[0m[38;5;8mc23d4b[39m [38;5;1mconflict[39m
◉ [1m[39mr[0m[38;5;8mlvkpnrz[39m hidden [38;5;[email protected][39m [38;5;6m2001-02-03 08:05:09[39m [1m[38;5;4mc[0m[38;5;8mf73917d[39m [38;5;1mconflict[39m
│ my description
◉ rlvkpnrz hidden [38;5;[email protected] 2001-02-03 08:05:09 6fbba7bc
│ my description
◉ [1m[39mr[0m[38;5;8mlvkpnrz[39m hidden [38;5;[email protected][39m [38;5;6m2001-02-03 08:05:08[39m [1m[38;5;4mea[0m[38;5;8mc0d0da[39m
◉ [1m[39mr[0m[38;5;8mlvkpnrz[39m hidden [38;5;[email protected][39m [38;5;6m2001-02-03 08:05:08[39m [1m[38;5;4me[0m[38;5;8mac0d0da[39m
(empty) my description
"###);

Expand All @@ -66,7 +66,7 @@ fn test_obslog_with_or_without_diff() {
│ 5 : foo
│ 6 : bar
│ 7 : >>>>>>>
◉ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 ebc23d4b conflict
◉ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 cf73917d conflict
│ my description
◉ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 6fbba7bc
│ my description
Expand All @@ -84,7 +84,7 @@ fn test_obslog_with_or_without_diff() {
insta::assert_snapshot!(stdout, @r###"
@ rlvkpnrz [email protected] 2001-02-03 08:05:10 66b42ad3
│ my description
◉ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 ebc23d4b conflict
◉ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 cf73917d conflict
│ my description
"###);

Expand All @@ -93,7 +93,7 @@ fn test_obslog_with_or_without_diff() {
insta::assert_snapshot!(stdout, @r###"
rlvkpnrz [email protected] 2001-02-03 08:05:10 66b42ad3
my description
rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 ebc23d4b conflict
rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 cf73917d conflict
my description
rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 6fbba7bc
my description
Expand All @@ -119,7 +119,7 @@ fn test_obslog_with_or_without_diff() {
-bar
->>>>>>>
+resolved
rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 ebc23d4b conflict
rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 cf73917d conflict
my description
rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 6fbba7bc
my description
Expand Down Expand Up @@ -162,7 +162,7 @@ fn test_obslog_with_custom_symbols() {
insta::assert_snapshot!(stdout, @r###"
$ rlvkpnrz [email protected] 2001-02-03 08:05:10 66b42ad3
│ my description
┝ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 ebc23d4b conflict
┝ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 cf73917d conflict
│ my description
┝ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 6fbba7bc
│ my description
Expand Down
Loading

0 comments on commit 2f4a553

Please sign in to comment.