git-passport icon indicating copy to clipboard operation
git-passport copied to clipboard

pre-commit not called during git init

Open holocronweaver opened this issue 10 years ago • 2 comments

I tried git 1.9.* (several subversions) and 2.2.2, and none triggered the pre-commit hook during git init. The hooks were successfully copied from the templates folder, and triggered successfully when I tried to commit, but the README gives the impression a simple git init should trigger pre-commit. Is this a change in more recent git versions? If so, is there a hook that runs during git init, or is some other hook or method necessary?

holocronweaver avatar Jan 29 '15 23:01 holocronweaver

That's the intended behaviour - git init doesn't trigger the git-passport hook since it is a pre-commit hook. All git init does is to copy templates to the local .git directory of a git repository. Then on the first commit the hook gets triggered and lets you select a passport. Alternatively you can just call git passport -s inside that repository to select a passport.

From git init --help:

Running git init in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning git init is to pick up newly added templates (or to move the repository to another place if --separate-git-dir is given).

Do you think I should describe the procedure more clearly in the README?

frace avatar Jan 30 '15 00:01 frace

Thanks for the clarification. Maybe a couple examples showing the alternative ways to use the library would make things crystal clear for new users, especially for those like me who have little experience with git hooks.

Something like:

cd /my/get/repo
git passport

and

cd /my/git/repo
git init              # Only necessary if repo existed prior to passport installation.
... do some work and stage files for commit  ...
git commit -m 'If you set up hooks correctly, this will trigger passport before committing.'

Also, giving at least one usage example near the top give visitors a quick taste of what git passport offers.

holocronweaver avatar Jan 30 '15 01:01 holocronweaver