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

Doesn't work for me #2

Closed
marcusyoung opened this issue Oct 9, 2020 · 29 comments
Closed

Doesn't work for me #2

marcusyoung opened this issue Oct 9, 2020 · 29 comments

Comments

@marcusyoung
Copy link

@vinsworldcom I just couldn't get this to work unfortunately. None of the operations (like commit, pull etc) do anything, there's a bit of a flash on the screen and then nothing. SCM is installed and working (integrated fine with several other applications).

@vinsworldcom
Copy link
Owner

Are you using the latest version? If so, you need to configure your path to git.exe:

Plugins => Git SCM => Settings

image

You should also check / uncheck "Use TortoiseGit" depending on whether or not you have TortoiseGit installed.

Cheers.

@marcusyoung
Copy link
Author

Yes, using latest version. And path is correct.

image

I don't have TortoiseGit installed and it's unchecked.

@marcusyoung
Copy link
Author

@vinsworldcom Done a quick screencast to illustrate the issue:

http://youtu.be/n9tSz0jnGwc?hd=1

@vinsworldcom
Copy link
Owner

It could be a few things. First - is git.exe in your %PATH%?

Open a command prompt (Start => Run => cmd.exe) and type git and press Enter. You should get the Git help and not:

'git' is not recognized as an internal or external command,
operable program or batch file.

If it works, then maybe the space in your Git path could be an issue.

Try editing the $(NPP_DIRECTORY)\plugins\config\GitSCM.ini file (where $(NPP_DIRECTORY) is the directory where Notepad++ is installed). If you can't find the file there, try in your %USERPROFILE%\AppData\Roaming\Notepad++ directory or subdirectories there.

You'll want to change in the GitSCM.ini file:

GitPath=C:\Progra~1\Git\cmd

Cheers.

@marcusyoung
Copy link
Author

marcusyoung commented Oct 9, 2020

@vinsworldcom Yes, git.exe is in the path. Git is working fine on my computer. I'm using it all the time.

Tried the edit in the ini file. No effect. As you can see from my screencast, it is recognising that the file is under version control. The edited file is listed.

@vinsworldcom
Copy link
Owner

vinsworldcom commented Oct 9, 2020

OK - that screencast helps a lot. It seems you're trying to commit a file that isn't staged.

Note there is not "fancy" GUI for this plugin, it's just using Git command line unless you have TortoiseGit installed in which case you get nice GUI.

Try double-clicking the "M" in the list view. Or you can use the left facing green arrow to stage the file you want to commit. You should then see the "M" in list view move from the "W" column (working) to the "I" column (index). Then you can try the green checkmark to commit.

Do any of the other buttons work - like status or log?

Cheers.

@marcusyoung
Copy link
Author

@vinsworldcom I had done that but not in the video. Double-clicking the M or the green arrow don't do anything, nor right click Add. Just screen flashing again. No status and log don't work either. Basically nothing does anything except for the Git Prompt button.

@vinsworldcom
Copy link
Owner

Out of curiosity, what is your Notepad++

Settings => Preferences => Default Directory set to?

image

@vinsworldcom
Copy link
Owner

The reason I ask about git in your path is because the plugin relies on CMD.exe to run Git NOT Git Bash as you may be familiar. So if you always use Git through Git Bash, it is possible that CMD.exe still does not have Git in it's path an the plugin will not work. Since it is updating the list view, I'm inclined to think Git is in your CMD.exe path; however, the button for Status and Log for example should pop open a CMD.exe prompt, execute the appropriate git command and the Pause / press any key to continue.

Have you tried installing TortoiseGit - a shell overlay that uses your existing Git for Windows install? It will provide a much nicer experience if working.

Cheers.

@vinsworldcom
Copy link
Owner

For "status" for example, the plugin generates a command based on where your Git Path is configured (in Settings). The command for "status", in your case would be:

cmd /c "C:\Program Files\Git\cmd\git.exe status && pause"

For me, that generates an error:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

As I suspected earlier with the space in the directory name. When you tried to edit the configuration file earlier:

  1. CLOSE ALL INSTANCES of Notepad++
  2. Use Windows Notepad or some other editor (other than Notepad++) to edit the GitSCM.ini configuration file and save
  3. Restart Notepad++

For me,

cmd /c "C:\Progra~1\Git\cmd\git.exe status && pause"

simply says it can't find git.exe since I don't have it installed there, but trying another program (e.g., Java) works with the "Progra~1" naming.

PS VinsWorldcom ~ > cmd /c "C:\Progra~1\Java\jdk-14.0.2\bin\java -version && pause"
openjdk version "14.0.2" 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-46)
OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)
Press any key to continue . . .

This is also import to have the Notepad++ Follow current Directory set as shown above since it will launch the cmd ... command in the directory of the current file. If this is not set, you will be running git status probably in your userprofile directory or Notepad++ install directory - surely not a git repo - and quickly exit with an error:

fatal: not a git repository (or any of the parent directories): .git

To find the 8.3 filename ("Progra~#") to use, open a Command Prompt:

Start => Run => cmd.exe

and run

dir /x \

Output like so:

C:\Users\VinsWorldcom>dir /x \
 Volume in drive C is WINDOWS
 Volume Serial Number is 1EB0-180A

 Directory of C:\

10/03/2020  08:05 PM    <DIR>          PROGRA~1     Program Files
09/18/2020  08:43 PM    <DIR>          PROGRA~2     Program Files (x86)

Since you said Git was installed in "Program Files", you would use "PROGRA~1". If Git 32-bit was installed in "Program Files (x86)" and you wanted to use that, you would use "PROGRA~2".

Cheers.

PS: Perhaps an enhancement for a future release would be to use a single ampersand before pause to execute the pause regardless of whether the git command exits cleanly. The double ampersand is conditional only on a clean exit of the previous command and so since git is failing for some reason, the pause never happens and the CMD.exe window disappears before you can read the error of what happened. Again, using TortoiseGit eliminates this kludge of pausing to keep CMD consoles open for reading by using a nice GUI.

@marcusyoung
Copy link
Author

Yes, git.exe is in the path. I have notepad++ default directory set to "remember last". Based on your further details on what the plugin is trying to do, I'll experiment some further tomorrow.

I have tried TortoiseGit with it, but also unsuccessful. With that I got the error "no working directory found" whenever any button was pressed. So had given up on that too!

@marcusyoung
Copy link
Author

Should add that TortoiseGit worked absolutely fine outside of the notepad++ plugin.

@vinsworldcom
Copy link
Owner

You need to change Notepad++ to "Follow current directory" and try. Otherwise you won't be launching got in the correct folder.

Cheers.

@marcusyoung
Copy link
Author

I'm afraid the change to "Follow current directory" hasn't resolved either the SCM or TortoiseGit issue. I will do more investigation tomorrow.

@marcusyoung
Copy link
Author

marcusyoung commented Oct 10, 2020

@vinsworldcom I have reinstalled git to c:\git to avoid any issues. Still doesn't work.

If I enter the following into Run command: cmd /c "cd c:\users\marcu\git-repos\otpr && C:\Git\bin\git.exe status && pause", I get:

image

So that's working.

If I open a file in the same repository in notepad++:

image

I click the status button and just get a flash.

Settings:

image

@marcusyoung
Copy link
Author

@vinsworldcom Interestingly, If I click the Gitk button now, I get:

image

But clearly it is a git repository as you can see from previous screenshot.

So I suspect the commands are not being run in the correct directory context.

Why I don't know. Directory setting as you suggested:

image

@marcusyoung
Copy link
Author

btw, I am on v7.9 64bit of notepad++

@marcusyoung
Copy link
Author

marcusyoung commented Oct 10, 2020

And, if I do File, Open Containing Folder, cmd in notepad++ it opens in the correct directory.

@vinsworldcom
Copy link
Owner

The cmd /c ... command you run you add a cd which I don't. I rely on Notepad++ to execute in the correct directory; hence the "Follow current directory" setting. This is strange as this setup works fine for me - Since early 7.x versions to the latest 7.9 on 64-bit.

I'm working on an update that may help troubleshoot ...

Cheers.

@marcusyoung
Copy link
Author

marcusyoung commented Oct 10, 2020

Yes, I understand that, I was merely replicating from the Run command what should be happening to confirm that the actual command was working (and that needed me to change to a repo directory).

@vinsworldcom
Copy link
Owner

I wonder if you'd be so included as to try the latest pre-release. You do not need to set the "Git Directory" in Settings - in fact you probably shouldn't to see what it picks up and how it works without.

You can manually edit the GitSCM.ini file to add the line:

Debug=1

That will use OutputDebugString() and you can open DebugView and filter on "git". You'll then see the command line calls the plugin is making. You'll notice there are no directories in any call and many don't have file names (like git status and git log) since I want the status or log for the repo, not an individual file. This means the plugin relies on Notepad++ "Follow current directory" to be set so the processes are launched in the directory of the current file - presumably in the git repo.

The Debug parameter must be set and unset manually in the config file as this is only for troubleshooting - it is not exposed in the UI.

Cheers.

@marcusyoung
Copy link
Author

@vinsworldcom With the pre-release, the status button now works. When I try and commit something I get this error:

Extensions.exe: No such file or directory
error: There was a problem with the editor '"C:/Program Files (x86)/GitExtensions/GitExtensions.exe" fileeditor'.
Please supply the message using either -m or -F option.
Press any key to continue . . .

Why's it trying to find GitExtensions?

@marcusyoung
Copy link
Author

I should add that TortoiseGit integration is working fine now.

@vinsworldcom
Copy link
Owner

vinsworldcom commented Oct 12, 2020

That's good news. I don't know what GitExtensions.exe is (assuming the program I linked to?) and there is no reference to it in the plugin. Note the Git plugin actually does very little if any "git" "stuff"; rather, it shells out system calls to git.exe and / or TortoiseGit.exe to do the heavy lifting. When "Commit" is pressed, it literally just calls git commit or TortoiseGit.exe /command:commit /path:"*"/closeonend:0. You can see that in the plugin code and you should be able to see that with the Debug=1 in the GitSCM.ini and DebugView running (as described above).

My guess is that you, Git for Windows, TortoiseGit, your local repo, global .gitconfig or some other program has set GitExtensions.exe "fileeditor" as your core.editor. I use nano.exe myself:

PS VinsWorldcom C:\usr\bin\npp64\plugins\GitSCM > git config core.editor
nano.exe

Where ever that is set, it looks like the syntax is not correct.

Cheers.

@marcusyoung
Copy link
Author

marcusyoung commented Oct 12, 2020

As you suggest, the core.editor is set to C:/Program Files (x86)/GitExtensions/GitExtensions.exe. Which does not exist on my PC and never has as far as I know. So I don't know what program has set that. I guess I either install that or set the editor to something else.

@vinsworldcom
Copy link
Owner

Weird. I would just set the editor to something else. I used to use regular Windows Notepad.exe. Both vim and nano are provided with Git for Windows, in the git\usr\bin subdirectory, where the "git" in that path is where ever you installed Git for WIndows (I think c:\git or C:\Program Files\Git from previous comments above).

I'm using nano as I mentioned, the following will set nano as your default Git editor for commit messages:

git config --global core.editor "nano"

Just replace "nano" with the editor of your choice (e.g., notepad, vim) providing it is installed on your system and in your PATH environment variable. I would not use Notepad++ as you may get conflicts with trying to open another instance - I was never able to get Notepad++ to open a new tab for a commit message - that would have been nice, but not working.

Cheers.

@marcusyoung
Copy link
Author

Now that TortoiseGit integration is working I may stick with that as it's actually pretty good.

@vinsworldcom
Copy link
Owner

vinsworldcom commented Oct 12, 2020

I'll be honest, I avoided TortoiseGit and went with Git for Windows for a consistent command line experience across Windows and Linux. But once I realized TortoiseGit was not a full Git client; rather a Windows Explorer add-on and GUI experience that just fron-ends your Git for Windows install - I was "all-in". The GUI makes the Notepad++ integration so much nicer and eliminates the need for my little plugin to create all sorts of Git integration - just shell out calls to TortoiseGit.

It's not perfect, sure it would be nice to do Git diffs directly in Notepad++ like the Compare plugin and do git status or logs in a Scintilla edit component or assign git blames in a Notepad++ margin, but I'm not that talented a C++ developer and this little plugin more than suits my minor Git needs.

Happy it worked out for you, sorry for so much trouble. I'll be making the 1.4.4.1 pre-release the latest release in week or so if there are no other issues.

Thanks for your patience.

Cheers.

@vinsworldcom
Copy link
Owner

Fixed in 1.4.4.1

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

No branches or pull requests

2 participants