ok/jj
1
0
Fork 0
forked from mirrors/jj

conflicts: indicate executable conflict in git-format diff

This commit is contained in:
Martin von Zweigbergk 2024-05-20 23:59:24 -07:00 committed by Martin von Zweigbergk
parent 07bb1d81b7
commit b227dde787
4 changed files with 28 additions and 11 deletions

View file

@ -467,7 +467,11 @@ fn diff_content(path: &RepoPath, value: MaterializedTreeValue) -> io::Result<Fil
contents: format!("Git submodule checked out at {}", id.hex()).into_bytes(),
}),
// TODO: are we sure this is never binary?
MaterializedTreeValue::Conflict { id: _, contents } => Ok(FileContent {
MaterializedTreeValue::Conflict {
id: _,
contents,
executable: _,
} => Ok(FileContent {
is_binary: false,
contents,
}),
@ -660,8 +664,13 @@ fn git_diff_part(path: &RepoPath, value: MaterializedTreeValue) -> io::Result<Gi
MaterializedTreeValue::Conflict {
id: _,
contents: conflict_data,
executable,
} => {
mode = "100644".to_string();
mode = if executable {
"100755".to_string()
} else {
"100644".to_string()
};
hash = "0000000000".to_string();
contents = conflict_data
}

View file

@ -184,7 +184,11 @@ fn read_file_contents(
item: "git submodule",
id: id.hex(),
}),
MaterializedTreeValue::Conflict { id: _, contents } => {
MaterializedTreeValue::Conflict {
id: _,
contents,
executable: _,
} => {
// TODO: Render the ID somehow?
let contents = buf_to_file_contents(None, contents);
Ok(FileInfo {

View file

@ -139,6 +139,7 @@ pub enum MaterializedTreeValue {
Conflict {
id: MergedTreeValue,
contents: Vec<u8>,
executable: bool,
},
GitSubmodule(CommitId),
Tree(TreeId),
@ -185,9 +186,15 @@ pub async fn materialize_tree_value(
materialize(&conflict, store, path, &mut contents)
.await
.expect("Failed to materialize conflict to in-memory buffer");
let executable = if let Some(merge) = conflict.to_executable_merge() {
merge.resolve_trivial().copied().unwrap_or_default()
} else {
false
};
Ok(MaterializedTreeValue::Conflict {
id: conflict,
contents,
executable,
})
}
}

View file

@ -1398,14 +1398,11 @@ impl TreeState {
MaterializedTreeValue::Tree(_) => {
panic!("unexpected tree entry in diff at {path:?}");
}
MaterializedTreeValue::Conflict { id, contents } => {
let executable = if let Some(merge) = id.to_executable_merge() {
merge.resolve_trivial().copied().unwrap_or_default()
} else {
false
};
self.write_conflict(&disk_path, contents, executable)?
}
MaterializedTreeValue::Conflict {
id: _,
contents,
executable,
} => self.write_conflict(&disk_path, contents, executable)?,
};
changed_file_states.push((path, file_state));
}