Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: git/git
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4e5821732e684f21a35288d8e67f453ca2595083
Choose a base ref
...
head repository: git/git
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5c58dbc887a1f3530cb29c995f63675beebb22e9
Choose a head ref
  • 13 commits
  • 20 files changed
  • 2 contributors

Commits on Mar 9, 2026

  1. Merge branch 'ar/config-hooks' into ar/config-hook-cleanups

    * ar/config-hooks: (21 commits)
      builtin/receive-pack: avoid spinning no-op sideband async threads
      hook: add -z option to "git hook list"
      hook: allow out-of-repo 'git hook' invocations
      hook: allow event = "" to overwrite previous values
      hook: allow disabling config hooks
      hook: include hooks from the config
      hook: add "git hook list" command
      hook: run a list of hooks to prepare for multihook support
      hook: add internal state alloc/free callbacks
      receive-pack: convert receive hooks to hook API
      receive-pack: convert update hooks to new API
      run-command: poll child input in addition to output
      hook: add jobs option
      reference-transaction: use hook API instead of run-command
      transport: convert pre-push to hook API
      hook: allow separate std[out|err] streams
      hook: convert 'post-rewrite' hook in sequencer.c to hook API
      hook: provide stdin via callback
      run-command: add stdin callback for parallelization
      run-command: add helper for pp child states
      ...
    gitster committed Mar 9, 2026
    Configuration menu
    Copy the full SHA
    8367733 View commit details
    Browse the repository at this point in the history

Commits on Mar 25, 2026

  1. hook: move unsorted_string_list_remove() to string-list.[ch]

    Move the convenience wrapper from hook to string-list since
    it's a more suitable place. Add a doc comment to the header.
    
    Also add a free_util arg to make the function more generic
    and make the API similar to other functions in string-list.h.
    Update the existing call-sites.
    
    Suggested-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    add3564 View commit details
    Browse the repository at this point in the history
  2. builtin/receive-pack: properly init receive_hook strbuf

    The run_receive_hook() stack-allocated `struct receive_hook_feed_state`
    is a template with initial values for child states allocated on the heap
    for each hook process, by calling receive_hook_feed_state_alloc() when
    spinning up each hook child.
    
    All these values are already initialized to zero, however I forgot to
    properly initialize the strbuf, which I left NULL.
    
    This is more of a code cleanup because in practice it has no effect,
    the states used by the children are always initialized, however it's
    good to fix in case someone ends up accidentally dereferencing the NULL
    pointer in the future.
    
    Reported-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    6b9f9e2 View commit details
    Browse the repository at this point in the history
  3. hook: fix minor style issues

    Fix some minor style nits pointed out by Patrick, Junio and Eric:
      * Use CALLOC_ARRAY instead of xcalloc.
      * Init struct members during declaration.
      * Simplify if condition boolean logic.
      * Missing curly braces in if/else stmts.
      * Unnecessary header includes.
      * Capitalization and full-stop in error/warn messages.
      * Curly brace on separate line when defining struct.
      * Comment spelling: free'd -> freed.
      * Sort the included headers.
      * Blank line fixes to improve readability.
    
    These contain no logic changes, the code behaves the same as before.
    
    Suggested-by: Eric Sunshine <sunshine@sunshineco.com>
    Suggested-by: Junio C Hamano <gitster@pobox.com>
    Suggested-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    b06770e View commit details
    Browse the repository at this point in the history
  4. hook: rename cb_data_free/alloc -> hook_data_free/alloc

    Rename the hook callback function types to use the hook prefix.
    
    This is a style fix with no logic changes.
    
    Suggested-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    8f7db6f View commit details
    Browse the repository at this point in the history
  5. hook: detect & emit two more bugs

    Trigger a bug when an unknown hook type is encountered while
    setting up hook execution.
    
    Also issue a bug if a configured hook is enabled without a cmd.
    
    Mostly useful for defensive coding.
    
    Suggested-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    4d10f4a View commit details
    Browse the repository at this point in the history
  6. hook: replace hook_list_clear() -> string_list_clear_func()

    Replace the custom function with string_list_clear_func() which
    is a more common pattern for clearing a string_list.
    
    To be able to do this, rework hook_clear() into hook_free(), so
    it can be passed to string_list_clear_func().
    
    A slight complication is the need to keep a copy of the internal
    cb data free() pointer, however I think it's worth it since the
    API becomes cleaner, e.g. no more calls with NULL function args
    like hook_list_clear(hooks, NULL).
    
    In other words, the callers don't need to keep track of hook
    internal state to determine when cleanup is necessary or not
    (pass NULL) because each `struct hook` now owns its data_free
    callback.
    
    Suggested-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    a8b1ba8 View commit details
    Browse the repository at this point in the history
  7. hook: make consistent use of friendly-name in docs

    Both `name` and `friendly-name` is being used. Standardize on
    `friendly-name` for consistency since name is rather generic,
    even when used in the hooks namespace.
    
    Suggested-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    2e5dbaf View commit details
    Browse the repository at this point in the history
  8. t1800: add test to verify hook execution ordering

    There is a documented expectation that configured hooks are
    run before the hook from the hookdir. Add a test for it.
    
    While at it, I noticed that `git hook list -h` runs twice
    in the `git hook usage` test, so remove one invocation.
    
    Suggested-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    e0fceec View commit details
    Browse the repository at this point in the history
  9. hook: introduce hook_config_cache_entry for per-hook data

    Replace the bare `char *command` util pointer stored in each string_list
    item with a heap-allocated `struct hook_config_cache_entry` that carries
    that command string.
    
    This is just a refactoring with no behavior changes, to give the cache
    entry room to grow, so it can carry the additional hook metadata we'll
    be adding in the following commits.
    
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    d8513bc View commit details
    Browse the repository at this point in the history
  10. hook: show config scope in git hook list

    Users running "git hook list" can see which hooks are configured but
    have no way to tell at which config scope (local, global, system...)
    each hook was defined.
    
    Store the scope from ctx->kvi->scope in the single-pass config callback,
    then carry it through the cache to the hook structs, so we can expose it
    to users via the "git hook list --show-scope" flag, which mirrors the
    existing git config --show-scope convention.
    
    Without the flag the output is unchanged.
    
    The scope is printed as a tab-separated prefix (like "git config --show-scope"),
    making it unambiguously machine-parseable even when the friendly name
    contains spaces.
    
    Example usage:
    $ git hook list --show-scope pre-commit
    global	linter
    local	no-leaks
    hook from hookdir
    
    Traditional hooks from the hookdir are unaffected by --show-scope since
    the config scope concept does not apply to them.
    
    Suggested-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    b66efad View commit details
    Browse the repository at this point in the history
  11. hook: show disabled hooks in "git hook list"

    Disabled hooks were filtered out of the cache entirely, making them
    invisible to "git hook list". Keep them in the cache with a new
    "disabled" flag which is propagated to the respective struct hook.
    
    "git hook list" now shows disabled hooks as tab-separated columns,
    with the status as a prefix before the name (like scope with
    --show-scope). With --show-scope it looks like:
    
    $ git hook list --show-scope pre-commit
    global	linter
    local	disabled	no-leaks
    hook from hookdir
    
    A disabled hook without a command issues a warning instead of the
    fatal "hook.X.command must be configured" error. We could also throw
    an error, however it seemd a bit excessive to me in this case.
    
    Suggested-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    e17bd99 View commit details
    Browse the repository at this point in the history
  12. hook: reject unknown hook names in git-hook(1)

    Teach "git hook run" and "git hook list" to reject hook event names
    that are not recognized by Git. This helps catch typos such as
    "prereceive" when "pre-receive" was intended, since in 99% of the
    cases users want known (already-existing) hook names.
    
    The list of known hooks is derived from the generated hook-list.h
    (built from Documentation/githooks.adoc). This is why the Makefile
    is updated, so builtin/hook.c depends on hook-list.h. In meson the
    header is already a dependency for all builtins, no change required.
    
    The "--allow-unknown-hook-name" flag can be used to bypass this check.
    
    Suggested-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    10ne1 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    5c58dbc View commit details
    Browse the repository at this point in the history
Loading