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

[Search git status] Preview only changes since file renamed #263

Merged
merged 20 commits into from
Oct 10, 2022

Conversation

PatrickF1
Copy link
Owner

@PatrickF1 PatrickF1 commented Oct 4, 2022

Previously, the git diff preview for a renamed path shows the entire file as being added. A more useful diff is to view only the modifications made to the file content. To accomplish this, we need a special condition for renames to diff the current (post-rename) path with the original path.

In addition, this PR fixes git status previews for renamed paths, which was accidentally broken in 38896f2.

@PatrickF1 PatrickF1 force-pushed the fix-preview-renamed-spaces branch from b905502 to fd55607 Compare October 4, 2022 21:18
@PatrickF1 PatrickF1 changed the title [Search git status] Fix previewing renamed paths with spaces [Search git status] Preview only changes since file renamed Oct 9, 2022
@@ -135,7 +135,7 @@ They are always appended last to fzf's argument list. Because fzf uses the optio

### Change the commands used to preview directories and regular files

The search directory feature, by default, calls `ls` to preview directories and `bat` to preview [regular files](https://stackoverflow.com/questions/6858452/what-is-a-regular-file-on-unix).
The search directory feature, by default, calls `ls` to preview directories and `bat` to preview [regular files](https://stackoverflow.com/questions/6858452).
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of scope change: realized I can shorten SO urls by only referencing up to the question id

end

_fzf_preview_changed_file "R file1 -> file2" >/dev/null
@test "only calls git diff staged for renamed files" $diff_working_called -eq 0 -a $diff_staged_called -eq 1
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test wasn't testing anything very useful

@PatrickF1 PatrickF1 force-pushed the fix-preview-renamed-spaces branch from 9961b0c to bd7fee6 Compare October 10, 2022 04:11
@PatrickF1 PatrickF1 merged commit 3a430c0 into main Oct 10, 2022
@PatrickF1 PatrickF1 deleted the fix-preview-renamed-spaces branch October 10, 2022 04:31
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