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

Untracking a file in the past with edits in latter commits produces errorring conflicted commits #1335

Closed
necauqua opened this issue Mar 4, 2023 · 4 comments
Labels
🐛bug Something isn't working good first issue Good for newcomers

Comments

@necauqua
Copy link
Collaborator

necauqua commented Mar 4, 2023

Description

When you add a file in some commit, edit it in some latter commit (in my case unintentionally, it was an IDE config that was auto-tracked and I forgot to gitignore it), and then try to edit the commit that added it to untrack it (add to gitignore and jj untrack) - latter commits that had edits to that file are then conflicted, but if you try to edit them you get this (newlines added after colons):

Internal error:
Failed to check out commit <hash>:
Failed to open file <file you untracked> for writing:
Os { code: 17, kind: AlreadyExists, message: "File exists" }

Steps to Reproduce the Problem

Here is a reproduction I've built:

jj init --git
echo 'a' > a.txt
echo 'z' > z.txt
touch .gitignore
jj commit -m 'add a.txt'
echo 'b' > b.txt
echo 'zz' >> z.txt
jj commit -m 'add b.txt'
jj edit @--
echo 'z.txt' > .gitignore
jj untrack z.txt
# the @+ (add b.txt) is conflicted now
jj edit @+ # this prints an error
jj st # this errors saying wc is stale
jj workspace update-stale # same error as edit
rm z.txt
jj workspace update-stale # now it works, and (add b.txt) is still conflicted, but this time on deletion vs (echo 'zz' >> z.txt) of z.txt

Expected Behavior

So, from the point of view of jj it is deleted - the bug is that the actual file (from the current commit too) is left there since it was just untracked, and checking out the commit with delete-vs-change conflict while the file does physically exist unbeknownst to jj produces the file-already-exists error, that actually makes sense. Not sure what exactly the expected behavior should be.

Actual Behavior

It errors and you have to delete the file (backing it up somewhere else), resolve the conflicts by confirming deletion in every commit that edited the file, and then restore the file because you wanted it to be there, just untracked.

Specifications

  • Platform: NixOS unstable
  • Version: d4b13d7
@PhilipMetzger PhilipMetzger added the 🐛bug Something isn't working label Mar 4, 2023
@martinvonz
Copy link
Owner

The simplest solution would be to leave conflicting files in the working copy. That would make them appear as changed after the update. It would be good to collect a list of files we didn't update so we can tell the user that we left them unchanged. I think this is the solution you proposed.

Alternatively, we could check first and tell the user if there are any conflict. However, that would be racy and we might still discover conflicting files when we update, so I don't really like that solution.

@martinvonz
Copy link
Owner

I think that's pretty straight-forward to implement, if you or anyone else wants to, btw.

@martinvonz martinvonz added the good first issue Good for newcomers label Mar 4, 2023
@yuja
Copy link
Collaborator

yuja commented Mar 5, 2023

Maybe this is the same as a general un-ignored file conflicts? #778, #976

@martinvonz
Copy link
Owner

Thanks, I had forgotten that we already had bugs for this. #778 seems to be exactly the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants