wincent / vcs-jump

🤾🏻‍♀️ Jump to interesting places with a Git or Mercurial repo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not getting any results

EduardoRT opened this issue · comments

Hi!

I'm not getting anything in my quickfix list after doing any of the VcsJump commands, :VcsJump diff, :VcsJump merge and :VcsJump grep - I do have ruby in my path and there's no error, I've tried with different git options like --cached and my staged changes don't appear either, I'm using Plug as my package manager and I'm on neovim 4.0.

Thanks!

@EduardoRT: Can you try running the vcs-jump executable from the command-line directly, outside of Vim, and see what it does?

For example, if you installed in ~/.vim/pack/bundle/opt/vcs-jump, it would be at ~/.vim/pack/bundle/opt/vcs-jump/bin/vcs-jump. Here's an example from a repo where I am now:

# Opens Vim with the changed files:
~/.vim/pack/bundle/opt/vcs-jump/bin/vcs-jump diff

# Instead of opening Vim, print the arguments that would be passed to Vim:
env EDITOR=/bin/echo ~/.vim/pack/bundle/opt/vcs-jump/bin/vcs-jump diff
-q /var/folders/yc/1x2y2qld1g95tvtjpd89hdrm0000gp/T/vcs-jump20190610-46050-hopk62

# Look inside the temporarily file that was echoed above to see which files Vim should open:
cat /var/folders/yc/1x2y2qld1g95tvtjpd89hdrm0000gp/T/vcs-jump20190610-46050-hopk62
apps/frontend-js/frontend-js-web/src/main/resources/META-INF/resources/liferay/side_navigation.es.js:232:
apps/frontend-js/frontend-js-web/src/main/resources/META-INF/resources/liferay/side_navigation.es.js:784: console.log('maybe subscribing', this.options.container);
apps/frontend-taglib/frontend-taglib-clay/src/main/resources/META-INF/resources/management_toolbar/ManagementToolbar.es.js:203: console.log('row toggled');

Running the executable directly from the command line opens vim with an status of E42: No Errors.

image

I can't get the second command to echo the tmp folders, it just opens neovim again with the same status - I'm on Ubuntu 18.10 if that helps.

I can't see how it would open Neovim if you have your EDITOR set to /bin/echo...

Try something else: what does git diff --relative print? (That's the command that vcs-jump is using to get the list of changes.)

git diff --relative gets me a correct diff (deleted random lines from one repo)

image

I've changed both VISUAL and EDITOR and when doing <C-x-e> it echos it out to a tmp file correctly but when running the vcs-jump command it still opens neovim.

image

Ah, I forgot... it will use GIT_EDITOR preferentially before EDITOR, so I think setting GIT_EDITOR=/bin/echo will do the trick.

If it doesn't you could just edit the script to make it print out what arguments it is going to pass to Vim:

diff --git a/bin/vcs-jump b/bin/vcs-jump
index 28c2c6b..cdd589f 100755
--- a/bin/vcs-jump
+++ b/bin/vcs-jump
@@ -35,7 +35,8 @@ def open_editor(tmp)
     additional_args = %w[-c :cw] # open the quickfix window
   end
 
-  exec(editor, '-q', tmp, *additional_args)
+  p editor, tmp, additional_args
+  # exec(editor, '-q', tmp, *additional_args)
 end
 
 def pwd

My guess here is that it's probably printing the right thing, so there must be some explanation for why your Neovim isn't doing the desired thing.

That did the trick, the tmp file is empty though

image

Weirdly enough, the :VcsJump merge command works as intended.

I wonder, are you in a subdirectory — not the project root — when you run it?

I am in the project root when running it :/

Well it's pretty odd that the file is empty. You can also try running it like this:

path/tobin/vcs-jump diff | cat

That should force it to print rather than write to a file.

Nada

image

At this point I don't know what to suggest other than adding some logging statements to see what the heck is going on.

diff --git a/bin/vcs-jump b/bin/vcs-jump
index 28c2c6b..4304625 100755
--- a/bin/vcs-jump
+++ b/bin/vcs-jump
@@ -103,7 +103,9 @@ end
 
 def mode_diff(args)
   args = shellescape(args)
+  puts "git? #{git?}"
   diff =  git? ? `git diff --relative #{args}` : `hg diff --git --root . #{args}`
+  puts diff
   idx  = nil
   file = nil
 
@@ -162,6 +164,8 @@ if STDOUT.tty?
   ensure
     tmp.close
   end
+
 else
+  puts "running: #{mode}"
   send("mode_#{mode}", ARGV)
 end

etc. If that doesn't reveal what's going on, add more logging statements.

Odd, when adding those statements I do get the expected diff

image

Weird, so the puts statement that dumps the diff printed it in color? That makes me wonder if you have something like git config color.ui set to "always" instead of auto... You could test that theory out by running: :VcsJump diff --color=never.

That was it! I did have the color config set to always, changing it to auto fixed the issue, maybe it's a good idea to add the --color=never flag to the VcsJump call?

Thanks @wincent ! The project is awesome :)

Yeah, I think adding --color=never is a good idea, and hopefully safe (I don't know exactly when it was added to Git, but it is probably ancient history by now).