Message ID | 20210527000856.695702-38-emilyshaffer@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | propose config-based hooks | expand |
On Wed, May 26 2021, Emily Shaffer wrote: > Since users may have an easier time finding 'man githooks' or 'git help > githooks' through tab-completion or muscle memory, reference the 'git > hook' commands. And in the 'git hook' manual, point users back to 'man > githooks' for specifics about the hook events themselves. Ok, there should be a cross-reference... > +HOOKS > +----- But this should be a "SEE ALSO" section. > +For a list of hooks which can be configured and how they work, see > +linkgit:githooks[5]. > + > CONFIGURATION > ------------- > include::config/hook.txt[] > diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt > index 42e66d4e2d..d780cb3b18 100644 > --- a/Documentation/githooks.txt > +++ b/Documentation/githooks.txt > @@ -7,15 +7,16 @@ githooks - Hooks used by Git > > SYNOPSIS > -------- > +'git hook' And ditto here, it makes no sense in a githooks(5) to put "git hook" in the SYNOPSIS section (which is usually commands to be run), that'll just spew out the --help output for "git hook" itself. > $GIT_DIR/hooks/* (or \`git config core.hooksPath`/*) > > > DESCRIPTION > ----------- > > -Hooks are programs you can place in a hooks directory to trigger > -actions at certain points in git's execution. Hooks that don't have > -the executable bit set are ignored. > +Hooks are programs you can specify in your config (see linkgit:git-hook[1]) or For most other things we link back to git-config[1] for such "see", even though we have the included config in the specific command. I can see how this makes more sense in a way, but would prefer to have us be consistent. > +place in a hooks directory to trigger actions at certain points in git's > +execution. Hooks that don't have the executable bit set are ignored. > > By default the hooks directory is `$GIT_DIR/hooks`, but that can be > changed via the `core.hooksPath` configuration variable (see Not a new issue, but is that "are ignored" not something that pre-dates "advice.ignoredHook"? I.e. we don't ignore them anymore, we warn about them, no?
diff --git a/Documentation/git-hook.txt b/Documentation/git-hook.txt index 81b8e94994..24e00a6f4a 100644 --- a/Documentation/git-hook.txt +++ b/Documentation/git-hook.txt @@ -17,6 +17,13 @@ DESCRIPTION You can list and run configured hooks with this command. Later, you will be able to add and modify hooks with this command. +In general, when instructions suggest adding a script to +`.git/hooks/<something>`, you can specify it in the config instead by running +`git config --add hook.<something>.command <path-to-script>` - this way you can +share the script between multiple repos. That is, `cp ~/my-script.sh +~/project/.git/hooks/pre-commit` would become `git config --add +hook.pre-commit.command ~/my-script.sh`. + This command parses the default configuration files for sections `hook` and `hookcmd`. `hook` is used to describe the commands which will be run during a particular hook event; commands are run in the order Git encounters them during @@ -141,6 +148,11 @@ number of CPUs on the current system. Some hooks may be ineligible for parallelization: for example, 'commit-msg' intends hooks modify the commit message body and cannot be parallelized. +HOOKS +----- +For a list of hooks which can be configured and how they work, see +linkgit:githooks[5]. + CONFIGURATION ------------- include::config/hook.txt[] diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt index 42e66d4e2d..d780cb3b18 100644 --- a/Documentation/githooks.txt +++ b/Documentation/githooks.txt @@ -7,15 +7,16 @@ githooks - Hooks used by Git SYNOPSIS -------- +'git hook' $GIT_DIR/hooks/* (or \`git config core.hooksPath`/*) DESCRIPTION ----------- -Hooks are programs you can place in a hooks directory to trigger -actions at certain points in git's execution. Hooks that don't have -the executable bit set are ignored. +Hooks are programs you can specify in your config (see linkgit:git-hook[1]) or +place in a hooks directory to trigger actions at certain points in git's +execution. Hooks that don't have the executable bit set are ignored. By default the hooks directory is `$GIT_DIR/hooks`, but that can be changed via the `core.hooksPath` configuration variable (see
Since users may have an easier time finding 'man githooks' or 'git help githooks' through tab-completion or muscle memory, reference the 'git hook' commands. And in the 'git hook' manual, point users back to 'man githooks' for specifics about the hook events themselves. Signed-off-by: Emily Shaffer <emilyshaffer@google.com> --- Documentation/git-hook.txt | 12 ++++++++++++ Documentation/githooks.txt | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-)