jj icon indicating copy to clipboard operation
jj copied to clipboard

The builtin diff editor for `jj split` mishandles truncating a file to 0 bytes

Open emesterhazy opened this issue 1 year ago • 3 comments

Steps to Reproduce the Problem

  1. Create a text file with contents and commit it.
  2. Create a second commit that truncates the contents to zero bytes but does not delete the file.
  3. Split the second commit and select all of the changes (i.e. the truncation).
  4. After the split, the first commit created by split will be empty and the second commit will truncate the file.

Expected Behavior

The first commit created by split should truncate the file and the second commit should be empty.

Actual Behavior

It's the opposite. The first commit is empty and the second commit truncates the file.

Specifications

  • Platform: MacOS
  • Version: Built from commit 62b14e1f

I synced back to before https://github.com/martinvonz/jj/pull/3481 and the bug existed then as well. I'm planning to look at this alongside https://github.com/arxanas/scm-record/issues/26 since they're closely related. scm-record has a few rough edges around empty files.

emesterhazy avatar Apr 17 '24 20:04 emesterhazy

Can confirm this happening. As someone who pretty much exclusively uses split this can be quite annoying ^^

30350n avatar May 10 '24 22:05 30350n

Fixing this upstream ended up being more complicated than I thought it would be and might require a change to the data model. I'm out for a week but I'm going to pick this back up when I'm back.

emesterhazy avatar May 11 '24 10:05 emesterhazy

Yeah I totally get that, no worries! Thanks for looking into it ❤️

30350n avatar May 11 '24 12:05 30350n

This has been fixed by https://github.com/jj-vcs/jj/pull/5486.

bnjmnt4n avatar Apr 04 '25 09:04 bnjmnt4n