eclipse-egit / egit

EGit, the git integration of Eclipse IDE
https://www.eclipse.org/egit/
Eclipse Public License 2.0
17 stars 7 forks source link

Integration with custom Git commands #16

Closed guw closed 7 months ago

guw commented 7 months ago

Description

We have a Git repository using a special plug-in/extension for push & pull. Pulling and pushing from EGit is broken with this repository because of the following error:

git: 'foo' is not a git command. See 'git --help'.
error: failed to push some refs to '...'

Motivation

Allow to push & pull from Eclipse.

Alternatives considered

No response

Additional context

No response

msohn commented 7 months ago

Don't know how we could help without knowing your extension.

guw commented 7 months ago

Do you see an OS level call-out to invoke the extension as possible generic solution?

tomaswolf commented 7 months ago

Not enough information. I'm confused by the error message; it seems to imply that a call-out to external git did already happen?

What's the extension, and how is it plugged into the push or pull process? Is "git foo" being called in some hook script?

guw commented 7 months ago

@tomaswolf That's a good hint. It's indeed a wired into hook. Maybe the PATH is not correct then JGit is executing the hooks? Is JGit executing the hooks?

tomaswolf commented 7 months ago

JGit is executing hooks. What platform? If Mac, I suspect you get the $PATH from Eclipse, which is typically much shorter than $PATH in a bash terminal if Eclipse was started via the UI. Dump $PATH from your hook script. (Or try starting Eclipse directly from a terminal to inherit the bash $PATH.)

However, the error message also implies that git itself was found and executed. But it could not find your custom command git-foo. Where is that git-foo located? Check the value of $GIT_EXEC_PATH in the hook. (Dump it, too.) Also dump the result of running git --exec-path.

And check that the git executable that gets run is the one you expect in case you have multiple installations. Check the order of directories inside $PATH.

guw commented 7 months ago

@tomaswolf Yes. It's Mac and very likely the path does not have /opt/homebrew in it.

Do you think it's worth having something like this in JGit? It's a utility I wrote to wrap execution into shell on MacOS so it has proper environment. I can contribute it to JGit if there is interest.

tomaswolf commented 7 months ago

There is already FS.runInShell(). I'm not at my development machine, so I cannot easily tell whether that is used to run hooks, but I would guess so. It already uses "sh -c". Perhaps it simply needs to be made to use "sh -l -c" on MacOS.

tomaswolf commented 7 months ago

I've pushed Gerrit change 1177212 for this.

guw commented 7 months ago

Thanks @tomaswolf. Looks like I cannot vote in the Gerrit instance. :( But +1

msohn commented 7 months ago

Gerrit change 1177212 was merged as 328008aa2937a5d0f539709fcf98a43c29ac6e95