Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: resolve: do not use .with_new_file_ids() to construct resolved file value #6288

Merged
merged 4 commits into from
Apr 13, 2025

Conversation

yuja
Copy link
Contributor

@yuja yuja commented Apr 8, 2025

Fixes #6250

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

@yuja yuja requested a review from a team as a code owner April 8, 2025 09:09
Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should instead make it an error to try to resolve the content-level conflict before resolving the executable-bit-level conflict. I think we should do the same when merging copy records, i.e. we should not pick one side but instead make the user decide which copy id to keep.

@yuja
Copy link
Contributor Author

yuja commented Apr 9, 2025

I think we should instead make it an error to try to resolve the content-level conflict before resolving the executable-bit-level conflict.

Just to clarify, instead of using .with_new_file_ids(), merge-tools should do 1. either resolve exec bit or error out by using to_executable_merge(), 2. construct resolved Merge with new file id + exec bit? That sounds good.

@martinvonz
Copy link
Member

Yes. I think it's fine to use .with_new_file_ids() after checking that there's no conflict in the executable bit (or copy id later). Maybe we can update the API somehow to reduce the risk of bugs like this one but I haven't thought about it.

@yuja
Copy link
Contributor Author

yuja commented Apr 9, 2025

it's fine to use .with_new_file_ids() after checking that there's no conflict in the executable bit (or copy id later).

I think the point of using .with_new_file_ids() is that it can retain the exec bit conflicts. Callers who have to merge exec bits don't need this property. They can just construct a resolved Merge.

yuja added a commit to yuja/jj that referenced this pull request Apr 9, 2025
…lved

This reverts a01d0bf "cli: resolve: leave executable bit unchanged when
using external tool", and adds test that would panic otherwise.

As Martin said, "we should instead make it an error to try to resolve the
content-level conflict before resolving the executable-bit-level conflict. I
think we should do the same when merging copy records."
jj-vcs#6288 (review)

Since exec bit has only two states, it can always be trivially resolved. We'll
need to think about the UI when we add CopyId handling.
@yuja yuja force-pushed the push-uomukxkrskus branch from 1b4242d to 3bf6c3a Compare April 9, 2025 12:46
@yuja yuja changed the title merge: relax with_new_file_ids() requirement, map absent to non-exec cli: resolve: do not use .with_new_file_ids() to construct resolved file value Apr 9, 2025
This seems a bit easier to follow than nesting Option types.
try_resolve_file_conflict() doesn't have this problem, but it is the only caller
of maybe_map(), so I've gone ahead and replaced it, too.

The return type is unchanged because it looked equally bad if to_tree_merge()
returned Result<Result<Merge<Tree>, ()>, BackendError>.
yuja added a commit to yuja/jj that referenced this pull request Apr 12, 2025
…olved

As Martin suggested, "we should instead make it an error to try to resolve the
content-level conflict before resolving the executable-bit-level conflict. I
think we should do the same when merging copy records."

jj-vcs#6288 (review)
@yuja yuja force-pushed the push-uomukxkrskus branch from 3bf6c3a to a6a844c Compare April 12, 2025 13:46
yuja added 3 commits April 12, 2025 23:30
We're going to make "jj resolve" error out on exec bit conflict. This behavior
should be more consistent with tree::try_resolve_file_conflict(), which exits
early if the tree value had absent entries.

Since unchanged exec bit shouldn't be lost when resolving change-delete content
conflict, the resolution function falls back to the original state if the
exec-bit conflict is resolved to None.
…olved

As Martin suggested, "we should instead make it an error to try to resolve the
content-level conflict before resolving the executable-bit-level conflict. I
think we should do the same when merging copy records."

jj-vcs#6288 (review)
…ile value

This reverts a01d0bf "cli: resolve: leave executable bit unchanged when
using external tool", and updates handling of resolved content.

Fixes jj-vcs#6250
@yuja yuja force-pushed the push-uomukxkrskus branch from a6a844c to ad716c2 Compare April 12, 2025 14:31
Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@yuja yuja added this pull request to the merge queue Apr 13, 2025
github-merge-queue bot pushed a commit that referenced this pull request Apr 13, 2025
…olved

As Martin suggested, "we should instead make it an error to try to resolve the
content-level conflict before resolving the executable-bit-level conflict. I
think we should do the same when merging copy records."

#6288 (review)
Merged via the queue into jj-vcs:main with commit fa00775 Apr 13, 2025
28 checks passed
@yuja yuja deleted the push-uomukxkrskus branch April 13, 2025 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jj resolve panics when resolving conflicts involving deleted files
2 participants