-
Notifications
You must be signed in to change notification settings - Fork 136
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
Improve forgit diff #189
Improve forgit diff #189
Conversation
For "git diff" to display a move/rename action correctly, it has to be passed both the old and the new file name. Change the gd preview command accordingly: instead of constructing a path out of the repo directory and the file name (which would not work with multiple file names), cd to the repo directory and use the file names as direct arguments to "git diff" instead. Change the regex used to parse the "git diff --name-status" output so that it supports the "Rxxx" syntax for moved/renamed files. Use tabs instead of hardcoded number of spaces along with "expand" to have file names horizontally aligned. Fixes wfxr#188
Show an arrow instead of just blank spaces when a file has been moved or renamed: [R100] foo.txt -> bar.txt The arrow is added as a replacement for the second tabspace of the "git diff --name-status" command. For the preview command it is replaced by a single space again.
LGTM! @carlfriedrich Thanks for your contribution! |
@carlfriedrich Will you post an example with screenshots of how #188 is supposed to work? Trying to move all this functionality over to fish, and I can't seem to get it to work. What I'm looking for is something like:
and posting some screenshots of how it looks on your side? Just want a nice reproducible target to aim for! |
1 similar comment
@carlfriedrich Will you post an example with screenshots of how #188 is supposed to work? Trying to move all this functionality over to fish, and I can't seem to get it to work. What I'm looking for is something like:
and posting some screenshots of how it looks on your side? Just want a nice reproducible target to aim for! |
@cjappl Sure, see the minimal example from the the description of #188:
Calling Notice the empty preview window and the wrongly displayed first line of the file list (state not in brackets, two filenames without context). With #188 merged the preview window works again with the diff showing the rename (this is with diff-so-fancy installed) and the file list displays the corresponding entry correctly: |
Beautiful!! Thanks for your contribution and this description, very helpful!! |
This had been fixed before in wfxr#189, but obviously the patch broke support for whitespaces in file names. That was fixed in wfxr#204, which in turn broke support for renames again. Unfortunately we cannot support both cases together with the existing 'xargs' implementation, because the arguments are interpreted either as one single file name (which breaks renames, because we have two files passed in this case) or as separate file names (which breaks whitespace support, because git would interpret each word of the file name as a separate file). This patch moves away from xargs and stores the file names in a bash array instead. This makes it possible to pass them to "git diff" quoted one by one using the "${array[@]}" notation.
This had been fixed before in #189, but obviously the patch broke support for whitespaces in file names. That was fixed in #204, which in turn broke support for renames again. Prepare the list of file names with the null-character \0 as a delimiter, so that we can use "xargs -0" to read it. This makes renames as well as filenames with spaces work correctly.
Check list
Description
Fix two bugs in
forgit::diff
:Type of change
Test environment