Closed keatsfonam closed 1 year ago
@keatsfonam Thanks for your bug report. I actually cannot reproduce this with zsh on Linux, gd
works fine here with your proposed steps:
Did this use to work in former versions of forgit? If so, can you maybe bisect this to a specific forgit version?
@keatsfonam Ah, from your screenshot I see that there's obviously a bug in the file list itself, which explains why the preview is not shown:
The arrow is inserted in these code lines:
eval "git diff --name-status $commits -- ${files[*]} | sed -E 's/^([[:alnum:]]+)[[:space:]]+(.*)$/[\1]\t\2/'" |
sed 's/\t/ -> /2' | expand -t 8 |
The second sed
command should replace a tab (which appears in the git output if files are renamed) with the ->
string. Obviously this command does not the right thing in your environment. Can you verify this by giving me the output of the following two commands:
echo -e "M\ttestfile" | sed 's/\t/ -> /2'
echo -e "R100\ttestfile\tmyfile" | sed 's/\t/ -> /2'
It should look like this:
@carlfriedrich here is the output, sorry for the delay
This is on OSX 10.15.7 with zsh 5.7.1 (x86_64-apple-darwin19.0)
sed doesn't have a version flag on OSX but here is an identifier: PROJECT:text_cmds-101.40.1
I also tested this on a linux box I have and the output looks like yours
@keatsfonam Thanks for your feedback. Unfortunately I don't have a Mac to verify this. Can you check if adding -E
to sed changes anything?
echo -e "M\ttestfile" | sed -E 's/\t/ -> /2'
echo -e "R100\ttestfile\tmyfile" | sed -E 's/\t/ -> /2'
I think you mixed up the -E on your sed and echo. Neither fix the problem. However I just found that adding a $ in front seems to resolve the problem as far as I can tell on all my various systems ANSI-C Quoting
https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
@keatsfonam Oh yes, I indeed mixed up the arguments in my example. Edited the post accordingly.
However, thanks for bringing up that solution! I will prepare a PR for that.
@keatsfonam I pushed PR #250 with a fix for this. Can you checkout the branch and verify that it fixes the issue for you?
The issue still occurs in the line above adding the tab
sed -E 's/^([[:alnum:]]+)[[:space:]]+(.*)$/[\1]\t\2/'"
Using a $ to quote this one did not work (output is just []). I just got it working fine for me by just using a literal tab instead of a \t character. Not sure if this is a universal solution.
EDIT:bin/git-forgit b/bin/git-for
index c79a40e..8717251 100755
--- a/bin/git-forgit
+++ b/bin/git-forgit
@@ -123,7 +123,7 @@ _forgit_diff() {
$FORGIT_DIFF_FZF_OPTS
--prompt=\"$commits > \"
"
- eval "git diff --name-status $commits -- ${files[*]} | sed -E 's/^([[:alnum:]]+)[[:space:]]+(.*)$/[\1]\t\2/'" |
+ eval "git diff --name-status $commits -- ${files[*]} | sed -E 's/^([[:alnum:]]+)[[:space:]]+(.*)$/[\1] \2/'" |
sed $'s/\t/ -> /2' | expand -t 8 |
FZF_DEFAULT_OPTS="$opts" fzf
fzf_exit_code=$?
@keatsfonam Thanks a lot for your feedback. I updated the branch in #250 with your proposed solution. Can you check again?
@carlfriedrich Works great, thanks.
Check list
Environment info
Problem / Steps to reproduce
gd is not showing anything in the preview pane. The file is detected. All other commands are correctly displaying the preview pane
Seems that it is similar to https://github.com/wfxr/forgit/issues/203 which was closed. There are no spaces in my filename.
To reproduce:
Here is![Screen Shot 2022-11-03 at 12 06 06 PM](https://user-images.githubusercontent.com/2251630/199811984-94a6bc23-9eb0-41d1-87e6-c472343d0a27.png)
gd
Here is![Screen Shot 2022-11-03 at 12 06 27 PM](https://user-images.githubusercontent.com/2251630/199812037-bd212297-fcf1-4940-a94e-da91b7b6cebb.png)
git diff
Here is![Screen Shot 2022-11-03 at 12 06 57 PM](https://user-images.githubusercontent.com/2251630/199812127-a13194b8-56e0-4bd7-9b66-f072cc4d3011.png)
glo
properly displaying