Add support for jj conflict markers (#6536)

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
Geoff Romer
2025-12-29 23:53:24 +00:00
committed by GitHub
co-authored by Chandler Carruth
parent 0e5874b203
commit 9cdb9c803a
+20 -2
View File
@@ -33,14 +33,32 @@ static auto TryConsumeConflictMarker(bool running_autoupdate,
bool& inside_conflict_marker)
-> ErrorOr<bool> {
bool is_start = line.starts_with("<<<<<<<");
bool is_middle = line.starts_with("=======") || line.starts_with("|||||||");
bool is_end = line.starts_with(">>>>>>>");
bool is_middle =
// git internal conflict markers ("merge" and "diff3" style).
line.starts_with("=======") ||
line.starts_with("|||||||")
// jj internal conflict markers ("snapshot" style).
|| line.starts_with("+++++++") || line.starts_with("-------");
// jj internal conflict marker ("diff" style)
bool is_jj_diff = line.starts_with("%%%%%%%");
// When running the test, any conflict marker is an error.
if (!running_autoupdate && (is_start || is_middle || is_end)) {
if (!running_autoupdate && (is_start || is_middle || is_end || is_jj_diff)) {
return ErrorBuilder() << "Conflict marker found:\n" << line;
}
if (is_jj_diff && running_autoupdate) {
// TODO: Add support for JJ's diff-style conflict markers.
return ErrorBuilder()
<< "Found jj \"diff\" style conflict marker."
" Autoupdate only supports \"snapshot\" style conflict markers."
" To switch, use `jj config set --repo ui.conflict-marker-style"
" \"snapshot\"`, and then run `jj new` (or `jj edit`) again to "
" materialize the new style. For more details, see: "
"https://docs.jj-vcs.dev/latest/conflicts/";
}
// Autoupdate tracks conflict markers for context, and will discard
// conflicting lines when it can autoupdate them.
if (inside_conflict_marker) {