From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Phillip Wood" <phillip.wood123@gmail.com>,
"René Scharfe" <l.s.r@web.de>,
"Emily Shaffer" <emilyshaffer@google.com>,
"Bagas Sanjaya" <bagasdotme@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v3 00/13] hook.[ch]: new library to run hooks + simple hook conversion
Date: Wed, 20 Oct 2021 01:20:38 +0200 [thread overview]
Message-ID: <cover-v3-00.13-00000000000-20211019T231647Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v2-00.13-00000000000-20211015T093918Z-avarab@gmail.com>
Part 2 of the greater configurable hook saga, starting by converting
some existing simple hooks to the new hook.[ch] library and "git hook
run" utility.
For more context:
See v2: https://lore.kernel.org/git/cover-v2-00.13-00000000000-20211015T093918Z-avarab@gmail.com
and v1: https://lore.kernel.org/git/cover-00.13-00000000000-20211012T131934Z-avarab@gmail.com/
Changes since v2:
* I got some of the s/struct hook/const char *hook_path/ conversion
wrong in v1->v2, which is the cause of the bug in "seen" with
t2400*.sh, this fixes that.
* The commit message for the git-p4 change was also out of date (made
sense before some previous re-ordering). I also updated a comment
there.
* Rebased on "master" for getting past a couple of small
conflicts. (seen in the range-diff).
* An include was happening in the wrong commit (was used later in the
series), moved.
Emily Shaffer (12):
hook: add 'run' subcommand
gc: use hook library for pre-auto-gc hook
rebase: convert pre-rebase to use hook.h
am: convert applypatch to use hook.h
hooks: convert 'post-checkout' hook to hook library
merge: convert post-merge to use hook.h
send-email: use 'git hook run' for 'sendemail-validate'
git-p4: use 'git hook' to run hooks
commit: convert {pre-commit,prepare-commit-msg} hook to hook.h
read-cache: convert post-index-change to use hook.h
receive-pack: convert push-to-checkout hook to hook.h
run-command: remove old run_hook_{le,ve}() hook API
Ævar Arnfjörð Bjarmason (1):
git hook run: add an --ignore-missing flag
.gitignore | 1 +
Documentation/git-hook.txt | 45 +++++++++++++
Documentation/githooks.txt | 4 ++
Makefile | 1 +
builtin.h | 1 +
builtin/am.c | 8 ++-
builtin/checkout.c | 14 ++--
builtin/clone.c | 7 +-
builtin/gc.c | 3 +-
builtin/hook.c | 90 +++++++++++++++++++++++++
builtin/merge.c | 4 +-
builtin/rebase.c | 8 ++-
builtin/receive-pack.c | 7 +-
builtin/worktree.c | 28 ++++----
command-list.txt | 1 +
commit.c | 15 +++--
git-p4.py | 70 ++-----------------
git-send-email.perl | 22 +++---
git.c | 1 +
hook.c | 121 +++++++++++++++++++++++++++++++++
hook.h | 56 ++++++++++++++++
read-cache.c | 11 ++-
reset.c | 14 ++--
run-command.c | 32 ---------
run-command.h | 17 -----
t/t1800-hook.sh | 134 +++++++++++++++++++++++++++++++++++++
t/t9001-send-email.sh | 4 +-
27 files changed, 550 insertions(+), 169 deletions(-)
create mode 100644 Documentation/git-hook.txt
create mode 100644 builtin/hook.c
create mode 100755 t/t1800-hook.sh
Range-diff against v2:
1: ba64faf0580 = 1: 02fd699e699 hook: add 'run' subcommand
2: e3dc0aed81b = 2: 42cc4d2c3c6 gc: use hook library for pre-auto-gc hook
3: 6227a1e644d ! 3: cbbfd77a4f6 rebase: convert pre-rebase to use hook.h
@@ builtin/rebase.c
#define DEFAULT_REFLOG_ACTION "rebase"
@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
- char *squash_onto_name = NULL;
int reschedule_failed_exec = -1;
int allow_preemptive_ff = 1;
+ int preserve_merges_selected = 0;
+ struct run_hooks_opt hook_opt = RUN_HOOKS_OPT_INIT;
struct option builtin_rebase_options[] = {
OPT_STRING(0, "onto", &options.onto_name,
4: 0e34eb54054 = 4: b26cef24f39 am: convert applypatch to use hook.h
5: a4df96c1719 ! 5: 2a747a65829 hooks: convert 'post-checkout' hook to hook library
@@ hook.c: static int notify_hook_finished(int result,
struct hook_cb_data cb_data = {
.rc = 0,
.hook_name = hook_name,
+- .hook_path = hook_path,
+ .options = options,
+ };
+ int jobs = 1;
@@ hook.c: int run_hooks(const char *hook_name, const char *hook_path,
if (!options)
BUG("a struct run_hooks_opt must be provided to run_hooks");
@@ hook.c: int run_hooks(const char *hook_name, const char *hook_path,
+ strbuf_add_absolute_path(&abs_path, hook_path);
+ hook_path = abs_path.buf;
+ }
++ cb_data.hook_path = hook_path;
+
run_processes_parallel_tr2(jobs,
pick_next_hook,
@@ hook.h: struct run_hooks_opt
#define RUN_HOOKS_OPT_INIT { \
- ## read-cache.c ##
-@@
- #include "sparse-index.h"
- #include "csum-file.h"
- #include "promisor-remote.h"
-+#include "hook.h"
-
- /* Mask for the name length in ce_flags in the on-disk index */
-
-
## reset.c ##
@@
#include "tree-walk.h"
6: 327f916f8c3 = 6: 7a9fd8627cd merge: convert post-merge to use hook.h
7: 328767015b1 = 7: 840fb530df3 git hook run: add an --ignore-missing flag
8: 6c4ebd68d56 = 8: 716ebabd794 send-email: use 'git hook run' for 'sendemail-validate'
9: b1f52733e3c ! 9: 95782109270 git-p4: use 'git hook' to run hooks
@@ Commit message
Python, we can directly call 'git hook run'. We emulate the existence
check with the --ignore-missing flag.
- As this is the last hook execution in git.git to not go through "git
- hook run" or the hook.[ch] library we can now be absolutely sure that
- our assertion in hook.c that only hooks known by the generated (from
- githooks(5)) hook-list.h are permitted.
+ We're dropping the "verbose" handling added in 9f59ca4d6af (git-p4:
+ create new function run_git_hook, 2020-02-11), those who want
+ diagnostic output about how hooks are run are now able to get that via
+ e.g. the trace2 facility and GIT_TRACE=1.
Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## git-p4.py ##
@@ git-p4.py: def decode_path(path):
- return path
def run_git_hook(cmd, param=[]):
-- """Execute a hook if the hook exists."""
+ """Execute a hook if the hook exists."""
- if verbose:
- sys.stderr.write("Looking for hook: %s\n" % cmd)
- sys.stderr.flush()
@@ git-p4.py: def decode_path(path):
- use_shell = True
- return subprocess.call(cli, shell=use_shell)
-
-+ """args are specified with -a <arg> -a <arg> -a <arg>"""
+ args = ['git', 'hook', 'run', '--ignore-missing', cmd]
+ if param:
+ args.append("--")
10: dc31d98acdf = 10: 706426c8a79 commit: convert {pre-commit,prepare-commit-msg} hook to hook.h
11: 58b7689e4af ! 11: 39069a9c3ff read-cache: convert post-index-change to use hook.h
@@ Commit message
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## read-cache.c ##
+@@
+ #include "sparse-index.h"
+ #include "csum-file.h"
+ #include "promisor-remote.h"
++#include "hook.h"
+
+ /* Mask for the name length in ce_flags in the on-disk index */
+
@@ read-cache.c: static int do_write_locked_index(struct index_state *istate, struct lock_file *l
{
int ret;
12: ae1e2a82147 = 12: 9818078f1e5 receive-pack: convert push-to-checkout hook to hook.h
13: 289d5a2d849 = 13: 1bc080d3611 run-command: remove old run_hook_{le,ve}() hook API
--
2.33.1.1338.g20da966911a
next prev parent reply other threads:[~2021-10-19 23:21 UTC|newest]
Thread overview: 115+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 9:43 [PATCH v2 00/13] hook.[ch]: new library to run hooks + simple hook conversion Ævar Arnfjörð Bjarmason
2021-10-15 9:43 ` [PATCH v2 01/13] hook: add 'run' subcommand Ævar Arnfjörð Bjarmason
2021-10-15 16:24 ` Emily Shaffer
2021-10-15 17:53 ` Eric Sunshine
2021-10-19 23:08 ` Ævar Arnfjörð Bjarmason
2021-10-15 9:43 ` [PATCH v2 02/13] gc: use hook library for pre-auto-gc hook Ævar Arnfjörð Bjarmason
2021-10-15 16:24 ` Emily Shaffer
2021-10-15 9:43 ` [PATCH v2 03/13] rebase: convert pre-rebase to use hook.h Ævar Arnfjörð Bjarmason
2021-10-15 16:25 ` Emily Shaffer
2021-10-15 9:43 ` [PATCH v2 04/13] am: convert applypatch " Ævar Arnfjörð Bjarmason
2021-10-15 16:25 ` Emily Shaffer
2021-10-15 9:43 ` [PATCH v2 05/13] hooks: convert 'post-checkout' hook to hook library Ævar Arnfjörð Bjarmason
2021-10-15 16:25 ` Emily Shaffer
2021-10-15 9:43 ` [PATCH v2 06/13] merge: convert post-merge to use hook.h Ævar Arnfjörð Bjarmason
2021-10-15 16:26 ` Emily Shaffer
2021-10-15 9:43 ` [PATCH v2 07/13] git hook run: add an --ignore-missing flag Ævar Arnfjörð Bjarmason
2021-10-15 16:26 ` Emily Shaffer
2021-10-15 9:43 ` [PATCH v2 08/13] send-email: use 'git hook run' for 'sendemail-validate' Ævar Arnfjörð Bjarmason
2021-10-15 17:07 ` Emily Shaffer
2021-10-15 9:43 ` [PATCH v2 09/13] git-p4: use 'git hook' to run hooks Ævar Arnfjörð Bjarmason
2021-10-15 17:08 ` Emily Shaffer
2021-10-15 9:43 ` [PATCH v2 10/13] commit: convert {pre-commit,prepare-commit-msg} hook to hook.h Ævar Arnfjörð Bjarmason
2021-10-15 17:15 ` Emily Shaffer
2021-10-15 9:43 ` [PATCH v2 11/13] read-cache: convert post-index-change to use hook.h Ævar Arnfjörð Bjarmason
2021-10-15 17:17 ` Emily Shaffer
2021-10-15 9:43 ` [PATCH v2 12/13] receive-pack: convert push-to-checkout hook to hook.h Ævar Arnfjörð Bjarmason
2021-10-15 9:43 ` [PATCH v2 13/13] run-command: remove old run_hook_{le,ve}() hook API Ævar Arnfjörð Bjarmason
2021-10-15 17:18 ` Emily Shaffer
2021-10-15 16:23 ` [PATCH v2 00/13] hook.[ch]: new library to run hooks + simple hook conversion Emily Shaffer
2021-10-16 0:58 ` Junio C Hamano
2021-10-16 5:22 ` Eric Sunshine
2021-10-16 5:47 ` Ævar Arnfjörð Bjarmason
2021-10-16 18:04 ` Junio C Hamano
2021-10-16 18:10 ` Ævar Arnfjörð Bjarmason
2021-10-19 23:20 ` Ævar Arnfjörð Bjarmason [this message]
2021-10-19 23:20 ` [PATCH v3 01/13] hook: add 'run' subcommand Ævar Arnfjörð Bjarmason
2021-10-19 23:20 ` [PATCH v3 02/13] gc: use hook library for pre-auto-gc hook Ævar Arnfjörð Bjarmason
2021-10-19 23:20 ` [PATCH v3 03/13] rebase: convert pre-rebase to use hook.h Ævar Arnfjörð Bjarmason
2021-10-29 5:48 ` Junio C Hamano
2021-10-19 23:20 ` [PATCH v3 04/13] am: convert applypatch " Ævar Arnfjörð Bjarmason
2021-10-19 23:20 ` [PATCH v3 05/13] hooks: convert 'post-checkout' hook to hook library Ævar Arnfjörð Bjarmason
2021-10-29 5:55 ` Junio C Hamano
2021-10-19 23:20 ` [PATCH v3 06/13] merge: convert post-merge to use hook.h Ævar Arnfjörð Bjarmason
2021-10-19 23:20 ` [PATCH v3 07/13] git hook run: add an --ignore-missing flag Ævar Arnfjörð Bjarmason
2021-10-29 5:59 ` Junio C Hamano
2021-10-19 23:20 ` [PATCH v3 08/13] send-email: use 'git hook run' for 'sendemail-validate' Ævar Arnfjörð Bjarmason
2021-10-19 23:20 ` [PATCH v3 09/13] git-p4: use 'git hook' to run hooks Ævar Arnfjörð Bjarmason
2021-10-19 23:20 ` [PATCH v3 10/13] commit: convert {pre-commit,prepare-commit-msg} hook to hook.h Ævar Arnfjörð Bjarmason
2021-10-19 23:20 ` [PATCH v3 11/13] read-cache: convert post-index-change to use hook.h Ævar Arnfjörð Bjarmason
2021-10-19 23:20 ` [PATCH v3 12/13] receive-pack: convert push-to-checkout hook to hook.h Ævar Arnfjörð Bjarmason
2021-10-19 23:20 ` [PATCH v3 13/13] run-command: remove old run_hook_{le,ve}() hook API Ævar Arnfjörð Bjarmason
2021-10-29 6:27 ` [PATCH v3 00/13] hook.[ch]: new library to run hooks + simple hook conversion Junio C Hamano
2021-11-01 18:56 ` [PATCH v4 00/17] " Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 01/17] hook: add 'run' subcommand Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 02/17] hook API: add a run_hooks() wrapper Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 03/17] gc: use hook library for pre-auto-gc hook Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 04/17] am: convert {pre,post}-applypatch to use hook.h Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 05/17] hook API: add a run_hooks_l() wrapper Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 06/17] rebase: convert pre-rebase to use hook.h Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 07/17] am: convert applypatch-msg " Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 08/17] merge: convert post-merge " Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 09/17] hooks: convert non-worktree 'post-checkout' hook to hook library Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 10/17] hooks: convert worktree " Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 11/17] git hook run: add an --ignore-missing flag Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 12/17] send-email: use 'git hook run' for 'sendemail-validate' Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 13/17] git-p4: use 'git hook' to run hooks Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 14/17] commit: convert {pre-commit,prepare-commit-msg} hook to hook.h Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 15/17] read-cache: convert post-index-change to use hook.h Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 16/17] receive-pack: convert push-to-checkout hook to hook.h Ævar Arnfjörð Bjarmason
2021-11-01 18:56 ` [PATCH v4 17/17] run-command: remove old run_hook_{le,ve}() hook API Ævar Arnfjörð Bjarmason
2021-11-23 11:45 ` [PATCH v5 00/17] hook.[ch]: new library to run hooks + simple hook conversion Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 01/17] hook: add 'run' subcommand Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 02/17] hook API: add a run_hooks() wrapper Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 03/17] gc: use hook library for pre-auto-gc hook Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 04/17] am: convert {pre,post}-applypatch to use hook.h Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 05/17] hook API: add a run_hooks_l() wrapper Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 06/17] rebase: convert pre-rebase to use hook.h Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 07/17] am: convert applypatch-msg " Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 08/17] merge: convert post-merge " Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 09/17] hooks: convert non-worktree 'post-checkout' hook to hook library Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 10/17] hooks: convert worktree " Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 11/17] git hook run: add an --ignore-missing flag Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 12/17] send-email: use 'git hook run' for 'sendemail-validate' Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 13/17] git-p4: use 'git hook' to run hooks Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 14/17] commit: convert {pre-commit,prepare-commit-msg} hook to hook.h Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 15/17] read-cache: convert post-index-change to use hook.h Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 16/17] receive-pack: convert push-to-checkout hook to hook.h Ævar Arnfjörð Bjarmason
2021-11-23 11:46 ` [PATCH v5 17/17] run-command: remove old run_hook_{le,ve}() hook API Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 00/17] hook.[ch]: new library to run hooks + simple hook conversion Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 01/17] hook: add 'run' subcommand Ævar Arnfjörð Bjarmason
2022-01-07 21:53 ` Emily Shaffer
2022-01-07 23:08 ` Junio C Hamano
2021-12-22 3:59 ` [PATCH v6 02/17] hook API: add a run_hooks() wrapper Ævar Arnfjörð Bjarmason
2022-01-06 18:53 ` Glen Choo
2021-12-22 3:59 ` [PATCH v6 03/17] gc: use hook library for pre-auto-gc hook Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 04/17] am: convert {pre,post}-applypatch to use hook.h Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 05/17] hook API: add a run_hooks_l() wrapper Ævar Arnfjörð Bjarmason
2022-01-06 18:56 ` Glen Choo
2022-01-07 21:56 ` Emily Shaffer
2021-12-22 3:59 ` [PATCH v6 06/17] rebase: convert pre-rebase to use hook.h Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 07/17] am: convert applypatch-msg " Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 08/17] merge: convert post-merge " Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 09/17] hooks: convert non-worktree 'post-checkout' hook to hook library Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 10/17] hooks: convert worktree " Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 11/17] git hook run: add an --ignore-missing flag Ævar Arnfjörð Bjarmason
2022-01-06 19:33 ` Glen Choo
2021-12-22 3:59 ` [PATCH v6 12/17] send-email: use 'git hook run' for 'sendemail-validate' Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 13/17] git-p4: use 'git hook' to run hooks Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 14/17] commit: convert {pre-commit,prepare-commit-msg} hook to hook.h Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 15/17] read-cache: convert post-index-change to use hook.h Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 16/17] receive-pack: convert push-to-checkout hook to hook.h Ævar Arnfjörð Bjarmason
2021-12-22 3:59 ` [PATCH v6 17/17] run-command: remove old run_hook_{le,ve}() hook API Ævar Arnfjörð Bjarmason
2022-01-06 18:47 ` [PATCH v6 00/17] hook.[ch]: new library to run hooks + simple hook conversion Glen Choo
2022-01-07 21:48 ` Emily Shaffer
2022-01-07 22:01 ` Emily Shaffer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover-v3-00.13-00000000000-20211019T231647Z-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=bagasdotme@gmail.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
--cc=phillip.wood123@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).