Skip to content

Null out modification date of index entries when (un)staging lines #1034

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

Merged

Conversation

Cykelero
Copy link
Contributor

@Cykelero Cykelero commented Nov 23, 2024

This fixes an issue where GitUp wrote incorrect data to the index, causing both the Git CLI and GitUp itself to produce incorrect diffs.

Reproducing

  • Download the bear-themes repo
  • The file Red Graphite.theme has changes, and is fully staged. In it, unstage the remove/add deltas at line 9.
  • The index is now corrupted: GitUp doesn't show those line 9 changes in the workdir nor stage views, and the Git CLI thinks they're still staged.

Fix

For performance, when producing diffs, Git skips reading the contents of files under some conditions. Here, the bug is that Git skips reading our file because it assumes it's identical between the working directory and the stage. Setting the file's date to null in the index prevents that behavior.

Notes

This fix has been in use in Retcon since January 2024, with no noticed adverse effect.

This fixes an issue where Git would produce incorrect diffs; indicating that a given file was unchanged between the index and the workdir, even though it was different.
@Cykelero Cykelero force-pushed the fix-incorrect-diff-after-staging-lines branch from f7c52a3 to 3d52611 Compare November 23, 2024 14:35
@lucasderraugh
Copy link
Collaborator

Thanks, I'll take a look probably this weekend.

@lucasderraugh lucasderraugh merged commit d53d758 into git-up:master Dec 18, 2024
@lucasderraugh
Copy link
Collaborator

Thanks, looks like it improves that behavior.

@Cykelero Cykelero deleted the fix-incorrect-diff-after-staging-lines branch December 18, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants