milke / GitFinder-Issues

Bug and issue tracker for GitFinder - git client with macOS Finder integration
16 stars 1 forks source link

[Bug] Endless 'hooks' When Pulling/Updating #71

Closed luxlogica closed 3 years ago

luxlogica commented 3 years ago

On MacOS Big Sur (11.0.1), and GitFinder 1.6, sometimes I still get the 'stuck validating' issue, which requires me to quit and re-launch GitFinder. If I don't quit, strange things happen - like, for example, a 'hooks' menu that mysteriously appears, and stays there, spinning, forever...

Screen Shot 2020-11-14 at 10 56 09 am

The only way to stop the operation - and get the 'hooks' menu to go away - is to quit GitFinder.

I wish I could be more helpful, but I have been unable to reproduce this reliably. It seems to happen totally at random.

milke commented 3 years ago

Can you specify which operation(s) you try to perform when that happens? Also, do you have any hooks for that repository (look at reporoot/.git/hooks)? If EVERY time that it happens you see that "hooks" spinning gear spinning forever, that means the execution of the command got stuck in execution of an appropriate hook script.

Due to sandboxing restrictions, GitFinder executes git hooks in a bit indirect way; the first time it has to execute a hook, it will ask you to "install support for git hooks".

Screen Shot 2020-11-15 at 00 40 25

You've certainly went through that, since you see that hooks spinning gear. The hooks script is installed where GitFinder can access it regardless of sandboxing restrictions and then GitFinder executes that hook script, which in turn executes appropriate git hook script (passing in all necessary arguments and environment variables). GitFinder works the similar way with diff/merge tools.

That spinning gear means a git hook has being executed as a part of a git operation. Execution is synchronous, GitFinder has to wait for its termination before continuing, but it never does, so the operation is stuck. Note that it's not that the execution of the hook failed, then you'd get some error, like below:

Screen Shot 2020-11-15 at 01 08 09

Instead, the hook execution gets stuck for whatever reason.

If this is your case, let me know which operation you try to execute when the situation happens, then we'll determine which hook get stuck and then we'll examine it further.

luxlogica commented 3 years ago

@milke Thank you for your quick response!

It always seems to get stuck when I'm PULLING from the remote repository. I have not added any explicit git hooks to any of my repositories, but I wonder whether there might be other apps that do?... I've looked into the repositories where that has happened, and I can't see any explicitly declared git hooks there...

Where should I be looking? What can I do to help?

milke commented 3 years ago

I have not added any explicit git hooks to any of my repositories, but I wonder whether there might be other apps that do?

Yes, other applications can do it. For example, if you used some other git client to e.g. enable git-lfs functionality, it could add some hooks into your repository. That's just one example, there may be others.

Where should I be looking? What can I do to help?

In your repository root folder, there is a hidden .git folder and inside it there is hooks folder. git hooks are located there (more precisely, they can also reside in some special location and that location is then set in your repository configuration, but that's probably not your case). Do you see any executable files in there, like for example in the picture below?

Screen Shot 2020-11-15 at 16 42 22
luxlogica commented 3 years ago

Holy cow! Yes, indeed I do: there are 4 of them - and I did not expect to see any there...:

Screen Shot 2020-11-16 at 2 40 07 pm

Opening any of the executables, I see a shell script that is basically checking whether git-lfs is available - they all look like this:

#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-commit.\n"; exit 2; }
git lfs post-commit "$@"

Is that what is causing the issue? I wonder which git app is adding these scripts... Also, could Issue #72 also be related to this? - i.e., maybe another application has messed around with the .gitattributes file, and this is somehow confusing GitFinder?

milke commented 3 years ago

Yeah those hooks are added for git-lfs functionality and there are two ways they could've ended up there; 1) either you installed git-lfs CLI tool yourself and enabled git-lfs functionality on that repo using that tool, or 2) you enabled git-lfs functionality using some other git client, which has git-lfs tool embedded in its application bundle.

In case of 1), you can see where git-lfs tool is installed by executing in terminal which git-lfs. In any case, these hooks WERE NOT added by GitFinder. git-lfs tool (and other clients embedding the tool) needs those hooks to achieve some sort of integration between git-lfs and core-git functionality. However, GitFinder implements git-lfs completely natively with custom code and in conjunction with underlying libgit2 library and it doesn't need those hooks at all, hence it doesn't add them to the repository when you enable git-lfs functionality. If you're interested, you can read more about it here.

Anyway, since in your case those hooks never failed due to lack of git-lfs tool in your execution path (otherwise, you'd see something like at this picture)…

Screen Shot 2020-11-17 at 00 05 30

… I suspect you've got the tool installed somewhere (check with which git-lfs). And then that tool for some reason got stuck in execution, hence that "hooks" gear spinning endlessly.

luxlogica commented 3 years ago

@milke that is annoying: I definitely did not install git-lfs myself, and doing which git-lfs still yields "git-lfs not found". But I did download and try out a whole bunch of different git clients about 2 months ago - Tower, Sublime Merge, Fork,... - so it was probably one of them that messed around with my repos... At least they didn't install anything in my system - and now I know where to look.

Could Issue #72 have something to do with this, too? - ie., could one of those apps have done something to the .gitattributes file that could be causing issues for GitFinder?

milke commented 3 years ago

… so it was probably one of them that messed around with my repos...

Ah, don't be so harsh on them :-) They didn't really "mess up" your repos and besides, there aren't rally any other options available. Even the official git-lfs command line tool, coming from guys who came up with the idea of LFS (Large Files Storage) in the first place, does the same. Others just follow, because they use the same tool embedded in application bundles, as they do with the core-git command line tool as well. The thing is, due to what git-lfs actually achieves, the only way to integrate it with certain functionality of the core-git is via hooks. GitFinder doesn't need that, as it doesn't use core-git tool, but instead controls all aspects of every git operations directly, via linked libgit2 library. Consequently, GitFinder accomplish git-lfs tasks without using hooks.

The only annoying thing is that if a git-lfs functionality is enabled using some other client, it will add those hooks, but then if one deletes other clients and uses GitFinder only, GitFinder will execute unnecessary hooks, which would fail due to lack of git-lfs tool (like in the picture in my previous message).

Anyway, back to the main issue…

1. Remove those hooks and see if GitFinder gets stuck while pulling again (remove those hooks only if you plan not to use other git clients for git-lfs. If you do, then let them be, as other clients will need them).

2. If even after removing hooks GitFinder gets stuck while pulling (or any other operation) with indefinite progress bar animation, don't quit nor kill anything ,but first take process samples; open Activity Monitor.app, find GitFinder, ag.zigz.GitFinder.GitService and ag.zigz.GitFinder.KeychainService processes and take samples of them all. Also observe eventual increased CPU usage of the latter two.

milke commented 3 years ago

@luxlogica, I'm closing this. If you encounter the same problem again and have some additional info, which may help me to track it down, feel free to reopen.