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

pre-commit not called during git init #30

Open
holocronweaver opened this issue Jan 29, 2015 · 2 comments
Open

pre-commit not called during git init #30

holocronweaver opened this issue Jan 29, 2015 · 2 comments
Assignees

Comments

@holocronweaver
Copy link
Contributor

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 holocronweaver changed the title pre-commit not called during init pre-commit not called during git init Jan 29, 2015
@holocronweaver holocronweaver changed the title pre-commit not called during git init pre-commit not called during git init Jan 29, 2015
@frace
Copy link
Owner

frace commented Jan 30, 2015

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 frace self-assigned this Jan 30, 2015
@frace frace added the question label Jan 30, 2015
@holocronweaver
Copy link
Contributor Author

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.

@frace frace added docs bug and removed question labels Feb 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants