Bug 564372 - EGIT on startup always testing git command
Summary: EGIT on startup always testing git command
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 5.8   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 5.9   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-17 07:52 EDT by Dawid Pakula CLA
Modified: 2020-07-26 16:42 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dawid Pakula CLA 2020-06-17 07:52:04 EDT
As the result, in case when "git" command isn't available on Mac, it provoke window similar to this: https://i.stack.imgur.com/7O1N9.png
Comment 1 Thomas Wolf CLA 2020-06-17 13:16:11 EDT
JGit tries to figure out the location of the system-wide git config. Since that location is undefined, it calls

  GIT_EDITOR=echo git config --system --edit

which will print the location.

Now the Mac has this fancy dummy git that, unless the Xcode command-line tools have been installed, prompts you to do so. Installing the Xcode command-line tools will then install a real git.

I don't know of a way to find the git system config that doesn't involve calling git. So I have no idea how we could avoid that. Short of not even trying to find the system-wide git. Is there any way to figure out in a simple way whether the git executable found is a real git or this Xcode wrapper?
Comment 2 Dawid Pakula CLA 2020-06-17 15:11:44 EDT
Maybe solution from here: https://github.com/docksal/docksal/issues/1003
Comment 3 Thomas Wolf CLA 2020-06-17 16:30:42 EDT
That might indeed give us a way to avoid that stupid prompt. I had already noticed that the wrapper remains even after the Xcode tools are installed.

Normal (non-Apple) git gets installed in /usr/local/bin, but that is after /usr/bin on the path. Changing the $PATH in a terminal (for instance in .profile) doesn't change the $PATH for applications started via the GUI.

So on Mac we either say there's no git installed if that xcode incantation tells us that there's no xcode git, or we additionally check for /usr/local/bin/git and use that if it exists.
Comment 4 Matthias Sohn CLA 2020-06-17 16:37:23 EDT
what a mess

If git is installed using homebrew it's also linked from /usr/local/bin/git so it looks like this strategy should work.
Comment 5 Thomas Wolf CLA 2020-06-17 16:48:52 EDT
macports would probably install or link it as /opt/local/bin/git.

Another alternative to try to find git to try to find the system config is to make the location of the system git config settable from outside (new JGit API). Then we can in EGit add a preference for it and let the user specify the path if we can't figure it out ourselves.
Comment 6 Dawid Pakula CLA 2020-06-17 17:10:35 EDT
(In reply to Matthias Sohn from comment #4)
> what a mess
> 
> If git is installed using homebrew it's also linked from /usr/local/bin/git
> so it looks like this strategy should work.

For brew, which git return correct location. Someone can check macports?

So if works similar, when which git return /usr/bin/git, method from GitHub should be used to detect dummy file.
Comment 7 Matthias Sohn CLA 2020-06-17 17:17:04 EDT
on Mac we could also try to get these alternative installation paths by running
$ which git
Comment 8 Thomas Wolf CLA 2020-06-18 02:50:59 EDT
FS_POSIX.discoverGitExe does that on Mac; it runs

  bash --login -c 'which git'

which should find such a non-Apple git if the $PATH in bash has /usr/local/bin or /opt/local/bin before /usr/bin.

However, we first try to find it on $PATH directly.

So on Mac we need to do something like

   gitExe = findOnPath()
   if (gitExe == null || "/usr/bin/git".equals(gitExe)) {
     gitExe = findViaBash()
   }
   if ("/usr/bin/git".equals(gitExe)) {
     // Check via xcode-select, set to null if xcode not installed
   }
Comment 9 Thomas Wolf CLA 2020-06-19 03:21:25 EDT
@Dawid: I can try to fix this via this xcode-select, but unfortunately I have no Mac on which the Xcode command-line tools are not installed, so I won't be able to test. If I push a fix attempt, could you test it?
Comment 10 Dawid Pakula CLA 2020-06-19 06:42:53 EDT
(In reply to Thomas Wolf from comment #9)
> @Dawid: I can try to fix this via this xcode-select, but unfortunately I
> have no Mac on which the Xcode command-line tools are not installed, so I
> won't be able to test. If I push a fix attempt, could you test it?

I already installed command line utils, but I can easy prepare parallels virtual machine witch fresh macOS.
Comment 11 Eclipse Genie CLA 2020-06-19 09:39:10 EDT
New Gerrit change created: https://git.eclipse.org/r/165220
Comment 12 Thomas Wolf CLA 2020-06-20 11:19:35 EDT
(In reply to Eclipse Genie from comment #11)
> New Gerrit change created: https://git.eclipse.org/r/165220

I managed to set up a VirtualBox OS X (10.14) guest and install AdoptOpenJDK 11.0.7 and Eclipse for Java Developers 2020-06 in it.

1. xcode-setup -p exits with error code 2 if XCode isn't installed at all.
2. Eclipse indeed causes that dialog on each start, but continues to launch.
3. Updating EGit in that OS X guest to EGit nightly and then updating JGit
   from the above build's repo (downloaded as zip, URL is [1]) indeed solves
   the problem: Eclipse starts without causing that dialog.
4. At the same time, Eclipse using a JGit with the above patch running on my
   OS X host (which does have the XCode tools installed) works fine, too.

I didn't do any further checks (like verifying that if I install in the OS X guest the git from [2] and update the bash $PATH to use that, Eclipse picks up that one) because this OS X guest doesn't work right; it's super slow (much slower than my CentOS7 guest) and keeps losing the mouse and keyboard input for extended periods of time, so it's not really usable. Just setting up the VM took hours, and installing and updating Eclipse and verifying it avoids the prompt took a couple hours more :-(

So it'd still be good if Dawid could test a little more and confirm.

[1] https://ci.eclipse.org/jgit/job/stable/job/jgit.gerrit-pipeline/3333/artifact/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/target/repository/*zip*/repository.zip
[2] https://sourceforge.net/projects/git-osx-installer/
Comment 13 Dawid Pakula CLA 2020-06-20 12:37:22 EDT
I prepared fresh machine with AdoptJDK 11 and Eclipse PHP 2020-06. 

After install EGIT 5.9 (from nightly) and JGIT from linked repository annoying popup gone.

Later I installed git form git-osx-installer, it become available in Terminal.app (`which git` result is /usr/local/bin/git)  but not in eclipse. After eclipse restart annoying popup was back.

Reboot didn't help.
Comment 14 Thomas Wolf CLA 2020-06-20 12:49:18 EDT
Yeah, of course. Because after having determined the installed git, JGit just calls "git" instead of actually using the path it found! Yuck. Update a-coming.
Comment 15 Thomas Wolf CLA 2020-06-20 13:48:37 EDT
Dawid, could you try again after updating to the JGit from [1]? This one should work now whether no git is installed at all, non-Apple git, or Apple git, and should never cause the XCode prompt.

Unless there's still other places where JGit just calls plain "git". But AFAIK this is the only place.

[1] https://ci.eclipse.org/jgit/job/stable/job/jgit.gerrit-pipeline/3334/artifact/*zip*/archive.zip
Comment 17 Thomas Wolf CLA 2020-06-21 16:33:01 EDT
Managed to verify in three VirtualBox VMs: OS X Mojave, OS X HighSierra, and Windows 10. (The latter included to check that the change in FS.java didn't break anything.) On OS X works now as intended, never triggers the XCode prompt, and picks up a non-Apple git if set in the bash $PATH, and still works with the Apple git if the XCode tools are installed (and first on the bash $PATH).

Off-topic: Mojave isn't supported yet by VirtualBox, only HighSierra is. HighSierra works marginally better, but the lack of GPU support in the VM means mouse pointer tracking is laggy when there are animations or SWT dialogs. With Mojave, mouse pointer tracking just seems to stop completely. So neither VM is really useable. (I can understand the animations part, but SWT dialogs? Is SWT doing something that needs a lot of GPU all the time?)
Comment 18 Dawid Pakula CLA 2020-06-21 16:39:28 EDT
I'll test it tomorrow.

(In reply to Thomas Wolf from comment #17)
> Off-topic: Mojave isn't supported yet by VirtualBox, only HighSierra is.
> HighSierra works marginally better, but the lack of GPU support in the VM
> means mouse pointer tracking is laggy when there are animations or SWT
> dialogs. With Mojave, mouse pointer tracking just seems to stop completely.
> So neither VM is really useable. (I can understand the animations part, but
> SWT dialogs? Is SWT doing something that needs a lot of GPU all the time?)

Yeah, on Mac SWT is often clumsy, and consume a lot of GPU. It invalidate entire widget for every single change. Canvas use own scrolling, rather than cocoas one. I'm also afraid that because SWT consume all events (event if they are not used), this introduce additional overhead.
Comment 19 Thomas Wolf CLA 2020-06-21 16:50:40 EDT
(In reply to Dawid Pakula from comment #18)
> (In reply to Thomas Wolf from comment #17)
> > Off-topic: Mojave isn't supported yet by VirtualBox, only HighSierra is.
> > HighSierra works marginally better, but the lack of GPU support in the VM
> > means mouse pointer tracking is laggy when there are animations or SWT
> > dialogs. With Mojave, mouse pointer tracking just seems to stop completely.
> > So neither VM is really useable. (I can understand the animations part, but
> > SWT dialogs? Is SWT doing something that needs a lot of GPU all the time?)
> 
> Yeah, on Mac SWT is often clumsy, and consume a lot of GPU. It invalidate
> entire widget for every single change. Canvas use own scrolling, rather than
> cocoas one. I'm also afraid that because SWT consume all events (event if
> they are not used), this introduce additional overhead.

So far it only seems to be dialogs and the built-in web browser. Text editing works in Eclipse in the VM. Not quite as fast as in my Linux VM, but useable.
Comment 20 Thomas Wolf CLA 2020-07-05 06:01:51 EDT
(In reply to Dawid Pakula from comment #18)
> I'll test it tomorrow.

Dawid, did you have time to test this?