Skip to content

Commit

Permalink
merge_tools: preserve executable bit on resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
scott2000 committed Dec 22, 2024
1 parent afa2f2d commit 7bf31c1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* On Windows, workspace paths (printed by `jj root`) no longer use UNC-style
`\\?\` paths unless necessary.

* `jj resolve` no longer removes the executable bit on resolved files when using
an external merge tool.

## [0.24.0] - 2024-12-04

### Release highlights
Expand Down
7 changes: 6 additions & 1 deletion cli/src/merge_tools/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,12 @@ pub fn run_mergetool_external(
let new_tree_value = match new_file_ids.into_resolved() {
Ok(new_file_id) => Merge::normal(TreeValue::File {
id: new_file_id.unwrap(),
executable: false,
executable: conflict
.to_executable_merge()
.as_ref()
.and_then(Merge::resolve_trivial)
.copied()
.unwrap_or_default(),
}),
Err(new_file_ids) => conflict.with_new_file_ids(&new_file_ids),
};
Expand Down
22 changes: 8 additions & 14 deletions cli/tests/test_resolve_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,21 +1012,20 @@ fn test_resolve_conflicts_with_executable() {
);
let editor_script = test_env.set_up_fake_editor();

// TODO: resolving the conflict in "file1" should produce an executable, but it
// currently doesn't
// Test resolving the conflict in "file1", which should produce an executable
std::fs::write(&editor_script, b"write\nresolution1\n").unwrap();
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["resolve", "file1"]);
insta::assert_snapshot!(stdout, @r#""#);
insta::assert_snapshot!(stderr, @r#"
Resolving conflicts in: file1
Working copy now at: znkkpsqq 1a12c872 conflict | (conflict) conflict
Working copy now at: znkkpsqq eb159d56 conflict | (conflict) conflict
Parent commit : mzvwutvl 08932848 a | a
Parent commit : yqosqzyt b69b3de6 b | b
Added 0 files, modified 1 files, removed 0 files
There are unresolved conflicts at these paths:
file2 2-sided conflict including an executable
New conflicts appeared in these commits:
znkkpsqq 1a12c872 conflict | (conflict) conflict
znkkpsqq eb159d56 conflict | (conflict) conflict
To resolve the conflicts, start by updating to it:
jj new znkkpsqq
Then use `jj resolve`, or edit the conflict markers in the file directly.
Expand All @@ -1036,9 +1035,7 @@ fn test_resolve_conflicts_with_executable() {
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
@r##"
diff --git a/file1 b/file1
old mode 100755
new mode 100644
index 0000000000..95cc18629d
index 0000000000..95cc18629d 100755
--- a/file1
+++ b/file1
@@ -1,7 +1,1 @@
Expand All @@ -1056,22 +1053,21 @@ fn test_resolve_conflicts_with_executable() {
@"file2 2-sided conflict including an executable"
);

// TODO: resolving the conflict in "file2" should produce an executable, but it
// currently doesn't
// Test resolving the conflict in "file2", which should produce an executable
test_env.jj_cmd_ok(&repo_path, &["undo"]);
std::fs::write(&editor_script, b"write\nresolution2\n").unwrap();
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["resolve", "file2"]);
insta::assert_snapshot!(stdout, @r#""#);
insta::assert_snapshot!(stderr, @r#"
Resolving conflicts in: file2
Working copy now at: znkkpsqq 5b6d14ea conflict | (conflict) conflict
Working copy now at: znkkpsqq 4dccbb3c conflict | (conflict) conflict
Parent commit : mzvwutvl 08932848 a | a
Parent commit : yqosqzyt b69b3de6 b | b
Added 0 files, modified 1 files, removed 0 files
There are unresolved conflicts at these paths:
file1 2-sided conflict including an executable
New conflicts appeared in these commits:
znkkpsqq 5b6d14ea conflict | (conflict) conflict
znkkpsqq 4dccbb3c conflict | (conflict) conflict
To resolve the conflicts, start by updating to it:
jj new znkkpsqq
Then use `jj resolve`, or edit the conflict markers in the file directly.
Expand All @@ -1081,9 +1077,7 @@ fn test_resolve_conflicts_with_executable() {
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
@r##"
diff --git a/file2 b/file2
old mode 100755
new mode 100644
index 0000000000..775f078581
index 0000000000..775f078581 100755
--- a/file2
+++ b/file2
@@ -1,7 +1,1 @@
Expand Down

0 comments on commit 7bf31c1

Please sign in to comment.