-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Search git status] Preview only changes since file renamed (#263)
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.
- Loading branch information
Showing
6 changed files
with
60 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
aaaaaaaaaaa | ||
bbbbbbbbbbb | ||
ccccccccccc | ||
ddddddddddd | ||
eeeeeeeeeee | ||
fffffffffff | ||
ggggggggggg | ||
hhhhhhhhhhh | ||
iiiiiiiiiii | ||
jjjjjjjjjjj | ||
kkkkkkkkkkk | ||
lllllllllll | ||
mmmmmmmmmmm | ||
nnnnnnnnnnn | ||
ooooooooooo | ||
ppppppppppp | ||
qqqqqqqqqqq | ||
rrrrrrrrrrr | ||
sssssssssss | ||
ttttttttttt | ||
uuuuuuuuuuu | ||
vvvvvvvvvvv | ||
wwwwwwwwwww | ||
xxxxxxxxxxx | ||
yyyyyyyyyyy | ||
zzzzzzzzzzz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
tests/preview_changed_file/renamed_path_modifications.fish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
set orig_path "tests/_resources/alphabet 26 lines.txt" | ||
set renamed_path "tests/_resources/alphabet lines.txt" | ||
set added_line a-very-unique-line | ||
git mv $orig_path $renamed_path | ||
echo $added_line >>$renamed_path | ||
git add $renamed_path | ||
|
||
set output (_fzf_preview_changed_file "R \"$orig_path\" -> \"$renamed_path\"") | ||
|
||
# test that the added line shows up in the diff but not the entire file | ||
# "aaaaaaaaaa" is the first line in the file | ||
string match --entire --quiet $added_line $output && | ||
not string match --entire aaaaaaaaaa $output | ||
@test "shows only the modifications made to renamed file" $status -eq 0 | ||
|
||
git mv $renamed_path $orig_path | ||
git restore --staged --worktree $orig_path |