Skip to content

Fix unstaging renamed and copied files in the status view - #1467

Open
jayhemnani9910 wants to merge 1 commit into
jonas:masterfrom
jayhemnani9910:fix/unstage-rename
Open

jayhemnani9910 wants to merge 1 commit into
jonas:masterfrom
jayhemnani9910:fix/unstage-rename

Conversation

@jayhemnani9910

Copy link
Copy Markdown

Pressing u on a staged rename in the status view resets only the old path. The new path stays staged as added:

git mv a c            # status: R c
tig status, u on "R c"
git status --short    #  D a
                      # A  c     (expected: ?? c)

The next commit then adds c and keeps a. For a staged copy (C c, shown when a is also modified) u resets a and leaves c staged.

status_update_write passes old.name to git update-index --index-info, which for renames and copies is the source path. It now also removes new.name (mode 0), and for a copy leaves the source entry alone. The result matches git restore --staged a c.

#1233 is about unstaging renames from the stage view; this is the status view path.

Added test/status/unstage-rename-test and unstage-copy-test; both fail without the change. make test passes.

For a staged rename, only the old path was reset, so the new path stayed
staged as added. For a staged copy, the source path was reset instead of
the copy. Also remove the new path from the index.
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.

1 participant