Commit Graph

24600 Commits

Author SHA1 Message Date
Junio C Hamano
bb51938304 Merge branch 'vp/http-rate-limit-retries' into seen
The HTTP transport learned to react to "429 Too Many Requests".

* vp/http-rate-limit-retries:
  http: add support for HTTP 429 rate limit retries
  remote-curl: introduce show_http_message_fatal() helper
  strbuf_attach: fix call sites to pass correct alloc
  strbuf: pass correct alloc to strbuf_attach() in strbuf_reencode()
2026-03-09 16:20:03 -07:00
Junio C Hamano
7ae9222643 Merge branch 'jc/neuter-sideband-post-3.0' into seen
The final step, split from earlier attempt by Dscho, to loosen the
sideband restriction for now and tighten later at Git v3.0 boundary.

* jc/neuter-sideband-post-3.0:
  sideband: delay sanitizing by default to Git v3.0
2026-03-09 16:20:02 -07:00
Junio C Hamano
c333d057e8 Merge branch 'ab/clone-default-object-filter' into seen
"git clone" learns to pay attention to "clone.<url>.defaultObjectFilter"
configuration and behave as if the "--filter=<filter-spec>" option
was given on the command line.

Comments?

* ab/clone-default-object-filter:
  clone: add clone.<url>.defaultObjectFilter config
2026-03-09 16:20:01 -07:00
Junio C Hamano
13b9fe91da Merge branch 'ar/parallel-hooks' into seen
* ar/parallel-hooks:
  hook: allow runtime enabling extensions.hookStdoutToStderr
  hook: introduce extensions.hookStdoutToStderr
  hook: add per-event jobs config
  hook: add -j/--jobs option to git hook run
  hook: mark non-parallelizable hooks
  hook: allow parallel hook execution
  hook: parse the hook.jobs config
  config: add a repo_config_get_uint() helper
  repository: fix repo_init() memleak due to missing _clear()
2026-03-09 16:20:00 -07:00
Junio C Hamano
1e5a23e1c1 Merge branch 'ar/config-hook-cleanups' into seen
* ar/config-hook-cleanups:
  hook: show disabled hooks in "git hook list"
  hook: show config scope in git hook list
  hook: refactor hook_config_cache from strmap to named struct
  t1800: add test to verify hook execution ordering
  hook: make consistent use of friendly-name in docs
  hook: replace hook_list_clear() -> string_list_clear_func()
  hook: detect & emit two more bugs
  hook: rename cb_data_free/alloc -> hook_data_free/alloc
  hook: fix minor style issues
  hook: move unsorted_string_list_remove() to string-list.[ch]
2026-03-09 16:19:58 -07:00
Junio C Hamano
5ebe159b1d Merge branch 'ps/t9200-test-path-is-helpers' into seen
* ps/t9200-test-path-is-helpers:
  t9200: replace test -f/-d with modern path helpers
2026-03-09 16:19:56 -07:00
Pablo Sabater
b708776c7f t9200: replace test -f/-d with modern path helpers
Replace old style 'test -f' and 'test -d' with helpers
'test_path_is_file' and 'test_path_is_dir' respectively,
which make debugging a failing test easier by loudly
reporting what expectation was not met.

The instances were found with:

	git grep "test -[efd]" t/

Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09 16:18:32 -07:00
Junio C Hamano
b6cd74c212 Merge branch 'ty/setup-error-tightening' into jch
While discovering a ".git" directory, the code treats any stat()
failure as a sign that a filesystem entity .git does not exist
there, and ignores ".git" that is not a "gitdir" file or a
directory.  The code has been tightened to notice and report
filesystem corruption better.

* ty/setup-error-tightening:
  setup: improve error diagnosis for invalid .git files
2026-03-09 14:38:36 -07:00
Junio C Hamano
8fed0a5e57 Merge branch 'pt/promisor-lazy-fetch-no-recurse' into jch
The mechanism to avoid recursive lazy-fetch from promisor remotes
were not propagated properly to child "git fetch" processes, which
has been corrected.

Comments?

* pt/promisor-lazy-fetch-no-recurse:
  promisor-remote: prevent lazy-fetch recursion in child fetch
2026-03-09 14:38:36 -07:00
Junio C Hamano
5e66505754 Merge branch 'pt/fsmonitor-linux' into jch
The fsmonitor daemon has been implemented for Linux.

* pt/fsmonitor-linux:
  fsmonitor: convert shown khash to strset in do_handle_client
  fsmonitor: add tests for Linux
  fsmonitor: add timeout to daemon stop command
  fsmonitor: close inherited file descriptors and detach in daemon
  run-command: add close_fd_above_stderr option
  fsmonitor: implement filesystem change listener for Linux
  fsmonitor: rename fsm-settings-darwin.c to fsm-settings-unix.c
  fsmonitor: rename fsm-ipc-darwin.c to fsm-ipc-unix.c
  fsmonitor: use pthread_cond_timedwait for cookie wait
  compat/win32: add pthread_cond_timedwait
  fsmonitor: fix hashmap memory leak in fsmonitor_run_daemon
  fsmonitor: fix khash memory leak in do_handle_client
2026-03-09 14:38:36 -07:00
Junio C Hamano
3fb21b6e49 Merge branch 'tb/incremental-midx-part-3.2' into jch
Further work on incremental repacking using MIDX/bitmap

* tb/incremental-midx-part-3.2:
  midx: enable reachability bitmaps during MIDX compaction
  midx: implement MIDX compaction
  t/helper/test-read-midx.c: plug memory leak when selecting layer
  midx-write.c: factor fanout layering from `compute_sorted_entries()`
  midx-write.c: enumerate `pack_int_id` values directly
  midx-write.c: extract `fill_pack_from_midx()`
  midx-write.c: introduce `midx_pack_perm()` helper
  midx: do not require packs to be sorted in lexicographic order
  midx-write.c: introduce `struct write_midx_opts`
  midx-write.c: don't use `pack_perm` when assigning `bitmap_pos`
  t/t5319-multi-pack-index.sh: fix copy-and-paste error in t5319.39
  git-multi-pack-index(1): align SYNOPSIS with 'git multi-pack-index -h'
  git-multi-pack-index(1): remove non-existent incompatibility
  builtin/multi-pack-index.c: make '--progress' a common option
  midx: introduce `midx_get_checksum_hex()`
  midx: rename `get_midx_checksum()` to `midx_get_checksum_hash()`
  midx: mark `get_midx_checksum()` arguments as const
2026-03-09 14:38:35 -07:00
Junio C Hamano
93c67ab47a Merge branch 'lc/rebase-trailer' into jch
"git rebase" learns "--trailer" command to drive the
interpret-trailers machinery.

Comments?

* lc/rebase-trailer:
  rebase: support --trailer
  commit, tag: parse --trailer with OPT_STRVEC
  trailer: append trailers without fork/exec
  trailer: libify a couple of functions
  interpret-trailers: refactor create_in_place_tempfile()
  interpret-trailers: factor trailer rewriting
2026-03-09 14:38:35 -07:00
Junio C Hamano
6da7b35a7e Merge branch 'ac/help-sort-correctly' into jch
The code in "git help" that shows configuration items in sorted
order was awkwardly organized and prone to bugs.

* ac/help-sort-correctly:
  help: cleanup the contruction of keys_uniq
2026-03-09 14:38:34 -07:00
Junio C Hamano
89073068d3 Merge branch 'sa/replay-revert' into jch
"git replay" (experimental) learns, in addition to "pick" and
"replay", a new operating mode "revert".

* sa/replay-revert:
  replay: add --revert mode to reverse commit changes
  sequencer: extract revert message formatting into shared function
2026-03-09 14:38:34 -07:00
Junio C Hamano
fceeb2b96e Merge branch 'yc/histogram-hunk-shift-fix' into jch
The final clean-up phase of the diff output could turn the result of
histogram diff algorithm suboptimal, which has been corrected.

* yc/histogram-hunk-shift-fix:
  xdiff: re-diff shifted change groups when using histogram algorithm
2026-03-09 14:38:34 -07:00
Junio C Hamano
3aa926b533 Merge branch 'jc/neuter-sideband-fixup' into jch
Try to resurrect and reboot a stalled "avoid sending risky escape
sequences taken from sideband to the terminal" topic by Dscho.  The
plan is to keep it in 'next' long enough to see if anybody screams
with the "everything dropped except for ANSI color escape sequence"
default.

Comments?

* jc/neuter-sideband-fixup:
  sideband: drop 'default' configuration
  sideband: offer to configure sanitizing on a per-URL basis
  sideband: add options to allow more control sequences to be passed through
  sideband: do allow ANSI color sequences by default
  sideband: introduce an "escape hatch" to allow control characters
  sideband: mask control characters
2026-03-09 14:38:33 -07:00
Junio C Hamano
4ee969f6a2 Merge branch 'fp/t3310-unhide-git-failures' into jch
The construct 'test "$(command)" = expectation' loses the exit
status from the command, which has been fixed by breaking up the
statement into pieces.

* fp/t3310-unhide-git-failures:
  t3310: avoid hiding failures from rev-parse in command substitutions
2026-03-09 14:38:33 -07:00
Junio C Hamano
095de412de Merge branch 'mf/format-patch-cover-letter-format' into jch
"git format-patch --cover-letter" learns to use a simpler format
instead of the traditional shortlog format to list its commits with
a new --cover-letter-format option and format.commitListFormat
configuration variable.

* mf/format-patch-cover-letter-format:
  docs: add usage for the cover-letter fmt feature
  format-patch: add commitListFormat config
  format-patch: add ability to use alt cover format
  format-patch: move cover letter summary generation
  pretty.c: add %(count) and %(total) placeholders
2026-03-09 14:38:33 -07:00
Junio C Hamano
a625596f7e Merge branch 'jt/repo-structure-extrema' into jch
"git repo structure" command learns to report maximum values on
various aspects of objects it inspects.

* jt/repo-structure-extrema:
  builtin/repo: find tree with most entries
  builtin/repo: find commit with most parents
  builtin/repo: add OID annotations to table output
  builtin/repo: collect largest inflated objects
  builtin/repo: add helper for printing keyvalue output
  builtin/repo: update stats for each object
2026-03-09 14:38:32 -07:00
Junio C Hamano
c5469c0ef1 Merge branch 'sp/send-email-validate-charset' into jch
"git send-email" has learned to be a bit more careful when it
accepts charset to use from the end-user, to avoid 'y' (mistaken
'yes' when expecting a charset like 'UTF-8') and other nonsense.

* sp/send-email-validate-charset:
  send-email: validate charset name in 8bit encoding prompt
2026-03-09 14:38:32 -07:00
Junio C Hamano
54140f84b3 Merge branch 'ss/t9123-setup-inside-test-expect-success' into jch
Test clean-up.

* ss/t9123-setup-inside-test-expect-success:
  t9123: use test_when_finished for cleanup
2026-03-09 14:38:31 -07:00
Junio C Hamano
89818d2989 Merge branch 'sk/oidmap-clear-with-custom-free-func' into jch
A bit of OIDmap API enhancement and cleanup.

* sk/oidmap-clear-with-custom-free-func:
  builtin/rev-list: migrate missing_objects cleanup to oidmap_clear_with_free()
  oidmap: make entry cleanup explicit in oidmap_clear
2026-03-09 14:38:31 -07:00
Junio C Hamano
697652f516 Merge branch 'hn/status-compare-with-push' into jch
"git status" learned to show comparison between the current branch
and various other branches listed on status.compareBranches
configuration.

* hn/status-compare-with-push:
  status: clarify how status.compareBranches deduplicates
2026-03-09 14:38:29 -07:00
Junio C Hamano
51bd45f68c Merge branch 'ds/for-each-repo-w-worktree' into jch
"git for-each-repo" started from a secondary worktree did not work
as expected, which has been corrected.

* ds/for-each-repo-w-worktree:
  for-each-repo: simplify passing of parameters
  for-each-repo: work correctly in a worktree
  run-command: extract sanitize_repo_env helper
  for-each-repo: test outside of repo context
2026-03-09 14:38:29 -07:00
Junio C Hamano
329a4fda3a Merge branch 'ss/t3700-modernize' into jch
Test clean-up.

* ss/t3700-modernize:
  t3700: use test_grep helper for better diagnostics
  t3700: avoid suppressing git's exit code
2026-03-09 14:38:28 -07:00
Junio C Hamano
a967254688 Merge branch 'bc/sha1-256-interop-02' into jch
The code to maintain mapping between object names in multiple hash
functions is being added, written in Rust.

* bc/sha1-256-interop-02:
  object-file-convert: always make sure object ID algo is valid
  rust: add a small wrapper around the hashfile code
  rust: add a new binary object map format
  rust: add functionality to hash an object
  rust: add a build.rs script for tests
  rust: fix linking binaries with cargo
  hash: expose hash context functions to Rust
  write-or-die: add an fsync component for the object map
  csum-file: define hashwrite's count as a uint32_t
  rust: add additional helpers for ObjectID
  hash: add a function to look up hash algo structs
  rust: add a hash algorithm abstraction
  rust: add a ObjectID struct
  hash: use uint32_t for object_id algorithm
  conversion: don't crash when no destination algo
  repository: require Rust support for interoperability
2026-03-09 14:38:27 -07:00
Junio C Hamano
9c89e91d04 Merge branch 'pt/fsmonitor-watchman-sample-fix' into jch
Fix typo-induced breakages in fsmonitor-watchman sample hook.

* pt/fsmonitor-watchman-sample-fix:
  fsmonitor-watchman: fix variable reference and remove redundant code
2026-03-09 14:38:27 -07:00
Junio C Hamano
81ed988384 Merge branch 'mm/diff-no-index-find-object' into jch
"git diff --no-index --find-object=<object-name>" outside a
repository of course wouldn't be able to find the object and died
while parsing the command line, which is made to die in a bit more
user-friendly way.

* mm/diff-no-index-find-object:
  diff: fix crash with --find-object outside repository
2026-03-09 14:38:27 -07:00
Junio C Hamano
ba6d9b81d8 Merge branch 'fp/t3310-test-path-is-helpers' into jch
Test clean-up.

* fp/t3310-test-path-is-helpers:
  t3310: replace test -f/-d with test_path_is_file/test_path_is_dir
2026-03-09 14:38:26 -07:00
Junio C Hamano
3ab592ba30 Merge branch 'ss/test-that-that-typofix' into jch
Typofix in t/.

* ss/test-that-that-typofix:
  t: fix "that that" typo in lib-unicode-nfc-nfd.sh
2026-03-09 14:38:26 -07:00
Junio C Hamano
78b9db7591 Merge branch 'kh/format-patch-noprefix-is-boolean' into jch
The configuration variable format.noprefix did not behave as a
proper boolean variable, which has now been fixed and documented.

* kh/format-patch-noprefix-is-boolean:
  doc: diff-options.adoc: make *.noprefix split translatable
  doc: diff-options.adoc: show format.noprefix for format-patch
  format-patch: make format.noprefix a boolean
2026-03-09 14:38:25 -07:00
Junio C Hamano
5aa2170a6b Merge branch 'jh/alias-i18n-fixes' (early part) into jch
* 'jh/alias-i18n-fixes' (early part):
  git, help: fix memory leaks in alias listing
  alias: treat empty subsection [alias ""] as plain [alias]
  doc: fix list continuation in alias subsection example
2026-03-09 14:38:25 -07:00
Junio C Hamano
bdea3a7fee Merge branch 'ar/config-hooks' (early part) into jch
* 'ar/config-hooks' (early part):
  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
2026-03-09 14:38:24 -07:00
Junio C Hamano
239331e2e1 Merge branch 'hn/status-compare-with-push' (early part) into jch
* 'hn/status-compare-with-push' (early part):
  status: add status.compareBranches config for multiple branch comparisons
  refactor format_branch_comparison in preparation
2026-03-09 14:38:24 -07:00
Junio C Hamano
e757df82af Merge branch 'lp/diff-stat-utf8-display-width-fix'
"git log --graph --stat" did not count the display width of colored
graph part of its own output correctly, which has been corrected.

* lp/diff-stat-utf8-display-width-fix:
  t4052: test for diffstat width when prefix contains ANSI escape codes
  diff: handle ANSI escape codes in prefix when calculating diffstat width
2026-03-09 14:36:55 -07:00
Junio C Hamano
3fe08b8fd1 Merge branch 'cs/add-skip-submodule-ignore-all'
"git add <submodule>" has been taught to honor
submodule.<name>.ignore that is set to "all" (and requires "git add
-f" to override it).

* cs/add-skip-submodule-ignore-all:
  Documentation: update add --force option + ignore=all config
  tests: fix existing tests when add an ignore=all submodule
  tests: t2206-add-submodule-ignored: ignore=all and add --force tests
  read-cache: submodule add need --force given ignore=all configuration
  read-cache: update add_files_to_cache take param ignored_too
2026-03-09 14:36:55 -07:00
Junio C Hamano
d445aecfb0 Merge branch 'ps/refs-for-each'
Code refactoring around refs-for-each-* API functions.

* ps/refs-for-each:
  refs: replace `refs_for_each_fullref_in()`
  refs: replace `refs_for_each_namespaced_ref()`
  refs: replace `refs_for_each_glob_ref()`
  refs: replace `refs_for_each_glob_ref_in()`
  refs: replace `refs_for_each_rawref_in()`
  refs: replace `refs_for_each_rawref()`
  refs: replace `refs_for_each_ref_in()`
  refs: improve verification for-each-ref options
  refs: generalize `refs_for_each_fullref_in_prefixes()`
  refs: generalize `refs_for_each_namespaced_ref()`
  refs: speed up `refs_for_each_glob_ref_in()`
  refs: introduce `refs_for_each_ref_ext`
  refs: rename `each_ref_fn`
  refs: rename `do_for_each_ref_flags`
  refs: move `do_for_each_ref_flags` further up
  refs: move `refs_head_ref_namespaced()`
  refs: remove unused `refs_for_each_include_root_ref()`
2026-03-09 14:36:55 -07:00
Junio C Hamano
5c56c725f1 Merge branch 'ar/run-command-hook-take-2'
Use the hook API to replace ad-hoc invocation of hook scripts via
the run_command() API.

* ar/run-command-hook-take-2:
  builtin/receive-pack: avoid spinning no-op sideband async threads
  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
  t1800: add hook output stream tests
2026-03-09 14:36:55 -07:00
Adrian Ratiu
863135ca3d hook: allow runtime enabling extensions.hookStdoutToStderr
Add a new config `hook.forceStdoutToStderr` which allows enabling
extensions.hookStdoutToStderr by default at runtime, both for new
and existing repositories.

This makes it easier for users to enable hook parallelization for
hooks like pre-push by enforcing output consistency. See previous
commit for a more in-depth explanation & alternatives considered.

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09 14:32:33 -07:00
Adrian Ratiu
8a101e3d2c hook: introduce extensions.hookStdoutToStderr
All hooks already redirect stdout to stderr with the exception of
pre-push which has a known user who depends on the separate stdout
versus stderr outputs (the git-lfs project).

The pre-push behavior was a surprise which we found out about after
causing a regression for git-lfs. Notably, it might not be the only
exception (it's the one we know about). There might be more.

This presents a challenge because stdout_to_stderr is required for
hook parallelization, so run-command can buffer and de-interleave
the hook outputs using ungroup=0, when hook.jobs > 1.

Introduce an extension to enforce consistency: all hooks merge stdout
into stderr and can be safely parallelized. This provides a clean
separation and avoids breaking existing stdout vs stderr behavior.

When this extension is disabled, the `hook.jobs` config has no
effect for pre-push, to prevent garbled (interleaved) parallel
output, so it runs sequentially like before.

Alternatives I've considered to this extension include:
1. Allowing pre-push to run in parallel with interleaved output.
2. Always running pre-push sequentially (no parallel jobs for it).
3. Making users (only git-lfs? maybe more?) fix their hooks to read
   stderr not stdout.

Out of all these alternatives, I think this extension is the most
reasonable compromise, to not break existing users, allow pre-push
parallel jobs for those who need it (with correct outputs) and also
future-proofing in case there are any more exceptions to be added.

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09 14:32:33 -07:00
Adrian Ratiu
24c7af4d22 hook: add per-event jobs config
Add a hook.<event>.jobs count config that allows users to override the
global hook.jobs setting for specific hook events.

This allows finer-grained control over parallelism on a per-event basis.

For example, to run `post-receive` hooks with up to 4 parallel jobs
while keeping other events at their global default:

[hook]
    post-receive.jobs = 4

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09 14:32:32 -07:00
Emily Shaffer
8d792d3ff5 hook: add -j/--jobs option to git hook run
Expose the parallel job count as a command-line flag so callers can
request parallelism without relying only on the hook.jobs config.

Add tests covering serial/parallel execution and TTY behaviour under
-j1 vs -jN.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09 14:32:32 -07:00
Emily Shaffer
0f993d3e98 hook: mark non-parallelizable hooks
Several hooks are known to be inherently non-parallelizable, so initialize
them with RUN_HOOKS_OPT_INIT_FORCE_SERIAL. This pins jobs=1 and overrides
any hook.jobs or runtime -j flags.

These hooks are:
applypatch-msg, pre-commit, prepare-commit-msg, commit-msg, post-commit,
post-checkout, and push-to-checkout.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09 14:32:32 -07:00
Emily Shaffer
31c9a1b13f hook: allow parallel hook execution
Hooks always run in sequential order due to the hardcoded jobs == 1
passed to run_process_parallel(). Remove that hardcoding to allow
users to run hooks in parallel (opt-in).

Users need to decide which hooks to run in parallel, by specifying
"parallel = true" in the config, because git cannot know if their
specific hooks are safe to run or not in parallel (for e.g. two hooks
might write to the same file or call the same program).

Some hooks are unsafe to run in parallel by design: these will marked
in the next commit using RUN_HOOKS_OPT_INIT_FORCE_SERIAL.

The hook.jobs config specifies the default number of jobs applied to all
hooks which have parallelism enabled.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-09 14:32:32 -07:00
Adrian Ratiu
86a30747ae 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 annotated with "(disabled)"
in the config order. With --show-scope, it looks like:

$ git hook list --show-scope pre-commit
linter (global)
no-leaks (local, disabled)
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>
2026-03-09 13:08:11 -07:00
Adrian Ratiu
dcd7ab7d2e 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.

Example usage:
$ git hook list --show-scope pre-commit
linter (global)
no-leaks (local)
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>
2026-03-09 13:08:11 -07:00
Adrian Ratiu
5c887b2712 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>
2026-03-09 13:08:11 -07:00
Adrian Ratiu
3f80ac69cf hook: fix minor style issues
Fix some minor style nits pointed by Patrick and Junio:
  * 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 in error/warn messages.
  * Comment spelling: free'd -> freed.

These contain no logic changes, the code behaves the same as before.

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>
2026-03-09 13:08:10 -07:00
Junio C Hamano
83677335ae 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
  ...
2026-03-09 13:07:50 -07:00
Francesco Paparatto
d3edca979a t3310: avoid hiding failures from rev-parse in command substitutions
Running `git` commands inside command substitutions like

    test "$(git rev-parse A)" = "$(git rev-parse B)"

can hide failures from the `git` invocations and provide little
diagnostic information when `test` fails.

Use `test_cmp` when comparing against a stored expected value so
mismatches show both expected and actual output. Use `test_cmp_rev`
when comparing two revisions. These helpers produce clearer failure
output, making it easier to understand what went wrong.

Suggested-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Francesco Paparatto <francescopaparatto@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-07 22:04:36 -08:00