jj-vcs / jj-vcs/jj

jj split inverting selected lines in a new file can unexpectedly result in an empty change

Open
#9,727 2 comments 0 reactions 0 assignees View on GitHub
🐛bug scm-record
Dominant language
Rust
Stars
31.6k
Forks
1.2k
Avg merge
2d 8h
Merged PRs (30d)
65

Description

## Description

If you `jj split` a change that has a new file added by selecting the lines you want in the second change and then pressing `a` to invert the change, the "File mode set to 100644" change will end up in the second change, which results in the first change being empty

## Steps to Reproduce the Problem

1. `echo "hello\nworld\n" > file`
1. `jj commit -m "commit"`
1. `jj split -r@-`
1. Select line 1 with ``. This will mark `File mode change` to be included as well.
1. Press `a` to invert selection. This will un-mark `File mode change`
1. Press `c` to confirm and accept the commit messages

## Expected Behavior

There should be two commits: one that creates `file` with `hello\n` and a second that adds `world\n` to `file`

## Actual Behavior

You end up with an empty change and a change that contains all of `file`.

## Specifications

- Platform: Windows and Linux
- Version: 0.42.0

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the documented commands on jj 0.42.0, then trace the interactive `jj split` selection handling, especially inversion after selecting a line in a newly added file. Confirm the fix by repeating the scenario and verifying that it produces two non-empty changes: one adding `hello` and one adding `world`.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.