Repository: carbon-language/carbon-lang
File: testing/file_test/test_file.cpp (C++)

Code before:
                                     llvm::StringRef line_trimmed,
                                     bool& inside_conflict_marker)
    -> ErrorOr<bool> {
  bool is_start = 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 || is_jj_diff)) {
    return ErrorBuilder() << "Conflict marker found:\n" << line;
  }

  if (is_jj_diff && running_autoupdate) {
    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 navigate to a different change and "
              "back.";
  }

  // Autoupdate tracks conflict markers for context, and will discard
  // conflicting lines when it can autoupdate them.
  if (inside_conflict_marker) {
    if (is_start) {
      return ErrorBuilder() << "Unexpected conflict marker inside conflict:\n"
                            << line;
    }
    if (is_middle) {
      return true;
    }
    if (is_end) {
      inside_conflict_marker = false;
      return true;
    }

    // Look for CHECK and TIP lines, which can be discarded.
    if (line_trimmed.starts_with("// CHECK:STDOUT:") ||
        line_trimmed.starts_with("// CHECK:STDERR:") ||
        line_trimmed.starts_with("// TIP:")) {
      return true;
    }

    return ErrorBuilder()

Review comment (suggestion):
I would phrase this slightly differently -- its not really about navigating away that materializes the conflict markers. Also might be worth giving folks a link here. Maybe:

```suggestion
              " 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/";
```

Code after:
                                     llvm::StringRef line_trimmed,
                                     bool& inside_conflict_marker)
    -> ErrorOr<bool> {
  bool is_start = 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 || 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) {
    if (is_start) {
      return ErrorBuilder() << "Unexpected conflict marker inside conflict:\n"
                            << line;
    }
    if (is_middle) {
      return true;
    }
    if (is_end) {
      inside_conflict_marker = false;
      return true;
    }

    // Look for CHECK and TIP lines, which can be discarded.
    if (line_trimmed.starts_with("// CHECK:STDOUT:") ||
        line_trimmed.starts_with("// CHECK:STDERR:") ||
        line_trimmed.starts_with("// TIP:")) {
      return true;
    }