Commit Graph

82141 Commits (d6cbbcd126ab12f1a8fd2c011c6a450a68c8e95f)

Author SHA1 Message Date
Patrick Steinhardt d6cbbcd126 builtin/multi-pack-index: refuse unknown sources with "--object-dir="
Users can tell git-multi-pack-index(1) to access multi-pack indices that
are stored in a different object directory via the "--object-dir="
option. This allows them to for example write or verify a multi-pack
index other than the one located in the main object directory in case a
repository has alternates with multiple multi-pack indices.

But while the documentation explicitly points out that the specified
object directory must be an alternate of the current repository, we
never verify that property. Instead, starting with 017db7bb14 (midx:
load multi-pack indices via their source, 2025-08-11), we now construct
an ad-hoc source and link it to the main object directory.

Besides contradicting the documentation, it's dubious that this really
ought to work in the first place: creating a multi-pack index (and
potentially a bitmap) for a completely foreign object directory is of
questionable value, as bitmap commit selection operates on the invoking
repository's refs. Furthermore, this is the only remaining caller
outside of our test helpers that constructs an ad-hoc source and links
it to the database, and we want to get rid of this mechanism as part of
this series.

Stop constructing the ad-hoc source and instead refuse the operation.
While this results in a change in behaviour, this restriction has been
documented as such ever since f57a739691 (midx: avoid opening multiple
MIDXs when writing, 2021-09-01).

Note that this change requires us to adapt one test chain in t5319, as
it creates an object directory that is not connected to any repository
and then uses it via "--object-dir=". The setup itself already documents
this and does the necessary gymnastics to link the object directory to a
temporary repository, but subsequent tests don't. Adapt those tests to
retain and reuse the temporary repository.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-01 10:55:42 -07:00
Patrick Steinhardt 6543910bad odb/packed: fix memory leaks when freeing source
When freeing a "packed" source we don't close either its packs nor its
multi-pack indices. This can cause memory leaks in case we create an
ad-hoc packed source. As we used to always link packed sources to the
main object database we never noticed this issue until now, but it's
going to surface in subsequent commits where we stop linking them.

Plug the memory leaks by closing the source first.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-01 10:55:42 -07:00
Patrick Steinhardt bb59f6b781 tmp-objdir: drop unused function to register alternate
The last caller of `tmp_objdir_add_as_alternate()` went away in
bdee7b3013 (builtin/receive-pack: stage incoming objects via ODB
transactions, 2026-07-10) and is unused now. Remove the function.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-01 10:55:42 -07:00
Patrick Steinhardt b84469ad6e odb: remove infrastructure to register submodule sources
The preceding commits have removed the last two users of
`odb_add_submodule_source_by_path()`. The mechanism was only ever
meant as a transitional crutch while migrating submodule object
access away from "add the submodule ODB as an alternate of
the_repository" towards explicitly passing the submodule repository,
see a35e03dee0 (submodule: lazily add submodule ODBs as alternates,
2021-08-16). Remove it.

As GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB is now a no-op, remove its
documentation and the exports from the test suite, as well.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-01 10:55:41 -07:00
Patrick Steinhardt 6f16066ff7 builtin/grep: stop registering submodule ODB as source
Same as with the preceding commit, git-grep(1) registers each
submodule's object database as an in-memory source of the main object
database before grepping it. This was introduced as an eager alternate
registration and converted into the lazy mechanism via 8d33c3af0b (grep:
use submodule-ODB-as-alternate lazy-addition, 2021-08-16).

Starting with 0693806bf8 (grep: add repository to OID grep sources,
2021-08-16), the command instead knows to pass submodule repositories to
our workers, which means that those now use that repository to look up
objects, too. As a consequence, registering submodule sources as
alternates is not required anymore.

Remove the logic to register submodule sources. Unfortunately, this does
not allow us to get rid of the object read lock as initializing the
subrepository is still racy.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-01 10:55:41 -07:00
Patrick Steinhardt 5dc4c496db submodule-config: stop registering submodule sources
When reading the ".gitmodules" file from a blob in a repository other
than `the_repository`, we register the repository's object database as
an in-memory source of `the_repository`'s object database. This call has
its origins in d9b8b8f896 (submodule-config.c: use repo_get_oid for
reading .gitmodules, 2019-04-16): back then, `config_with_options()` was
not able to read a blob from an arbitrary repository, but would always
read it via `the_repository`. So even though the blob could be resolved
in the submodule repository via `repo_get_oid()`, the submodule's object
database had to be registered as an in-memory source of `the_repository`
so that the subsequent object read was able to find the blob at all.

That need went away with e3e8bf046e (submodule-config: pass repo
upon blob config read, 2021-08-16), which taught the config machinery
to read the blob from the repository we pass to it. The same series
converted the eager submodule source registration into a lazy mechanism
that only registers submodule sources with the object database when an
object lookup failed. The intent though was that we don't ever have to
fall back to this mechanism in the first place, and to verify that this
is the case we introduced GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB. If set,
then any such lazy registration would cause us to BUG.

At the beginning of this series, we still triggered this bug in t1092.
But now that we have converted the "cache-tree" subsystem to not depend
on `the_repository` anymore it also knows to properly access objects via
the submodule. With that change, GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
does not cause any failures anymore.

Remove the call to `odb_add_submodule_source_by_path()`. This removes
the last user of `the_repository`, so at the same time we can also get
rid of `USE_THE_REPOSITORY_VARIABLE`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-01 10:55:41 -07:00
Patrick Steinhardt 92ed317b05 submodule-config: stop using `the_hash_algo`
We have two uses of `the_hash_algo` in "submodule-config.c":

  - One trivial use in `gitmodules_cb`, which we can convert to use the
    hash algorithm of the repository that's already available in the
    caller's context.

  - One use where we compute the hashmap key of an object ID. We should
    only ever get valid, populated object IDs here, and consequently we
    can easily adapt that function to use the hash algorithm of the
    passed-in object ID.

Adapt both sites accordingly. Safeguard us against the case where the
passed-in object ID is _not_ properly initialized. While this case
shouldn't ever happen, it doesn't hurt to be defensive.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-01 10:55:41 -07:00
Patrick Steinhardt a776b844d6 submodule-config: remove uses of `the_repository`
Several functions in the submodule-config subsystem implicitly depend
on `the_repository`. Refactor these to take a `struct repository` as
parameter and adapt callers accordingly.

Note that as usual with these refactorings, callers simply pass
`the_repository` even if they already have a different repository
available in the calling context. This simplifies the migration and
ensures that we don't have a change in behaviour.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-01 10:55:41 -07:00
Patrick Steinhardt 895156bb99 cache-tree: remove dependency on `the_repository`
The "cache-tree" subsystem still depends on `the_repository`. Adapt it
to instead use repositories provided via the context, either as a new
parameter or the one passed in via `struct index_state`.

Besides getting rid of `the_repository`, this also removes the last
dependency on registering submodule sources with the main object
database. When reading gitmodules from a submodule's index we implicitly
read that object via `the_repository`'s object database, which is of
course wrong. This works though because we would then register the
submodule's object database with the main object database, but a later
patch is going to get rid of that mechanism.

You can verify that we indeed no longer depend on this mechanism by
running tests with `GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=true`. Without
this patch we fail in t1092, with this patch we never register submodule
object databases anymore.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-01 10:55:41 -07:00
Junio C Hamano 004f98f28f Merge branch 'ty/repository-fetch-if-missing' into ps/ps/odb-stop-registering-in-memory-sources
* ty/repository-fetch-if-missing:
  repository: move fetch_if_missing into struct repository
2026-09-01 10:55:20 -07:00
Junio C Hamano 1630431f32 The 21st batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-31 08:25:00 -07:00
Junio C Hamano 6e75a57d1b Merge branch 'fr/pack-objects-trace-pack-bytes'
The pack-objects command has been updated to record the total bytes
written to pack files in trace2 output, allowing performance
analysis of different compression settings by comparing the
resulting pack sizes.

* fr/pack-objects-trace-pack-bytes:
  pack-objects: trace pack bytes written
2026-08-31 08:25:00 -07:00
Junio C Hamano 923bf36c46 Merge branch 'ps/odb-pluggable-pack-generation'
The mechanism to generate a packfile corresponding to the result of
a fetch/push has been made pluggable through a set of object
database callback functions, removing hardcoded references to
'pack-objects' and enabling alternative ODBs to serve packfiles
themselves.

* ps/odb-pluggable-pack-generation:
  bundle: generate packfiles via the object database
  bundle: get (mostly) rid of `the_repository`
  builtin/bundle: refactor option handling for progress meter
  send-pack: generate packfiles via the object database
  upload-pack: generate packfiles via the object database
  odb: introduce interface to generate packfiles
2026-08-31 08:25:00 -07:00
Junio C Hamano 26e1e47b47 Merge branch 'jt/receive-pack-pluggable-writes'
The 'git receive-pack' command has been updated to use a new ODB
transaction interface for writing incoming packfiles, making it more
backend-agnostic.

* jt/receive-pack-pluggable-writes:
  odb/transaction: add transaction interface to write packfiles
  odb: return temporary ODB source when set
  builtin/receive-pack: explicitly pass packfile fd
  builtin/receive-pack: report unpack errors via strbuf
  builtin/receive-pack: lift global state out of unpack()
  builtin/receive-pack: read unpack limit config lazily
  builtin/receive-pack: pass shallow file explicitly
  odb/transaction: add transaction finalize interface
  builtin/receive-pack: properly clean up keep files
2026-08-31 08:25:00 -07:00
Junio C Hamano 93f737d51b Merge branch 'ps/odb-geometric-repack-loose-threshold'
The threshold for geometric repacking to trigger based on loose
object count has been adjusted to match that of 'git gc --auto',
preventing over-aggressive repacking during concurrent writes.

* ps/odb-geometric-repack-loose-threshold:
  odb/files: be less aggressive with geometric repacking
2026-08-31 08:24:59 -07:00
Junio C Hamano 1e4d33de9b Merge branch 'kh/trailers-no-urls'
The trailer parsing machinery has been updated to avoid mistaking
lines that begin with a URL (e.g., 'https://...') as trailer lines.
This prevents intended textual URLs from being mangled or mistakenly
treated as metadata keys.

* kh/trailers-no-urls:
  trailers: stop recognizing URLs as trailers
2026-08-31 08:24:59 -07:00
Junio C Hamano 8b92a9cf4f Merge branch 'ps/odb-eagerly-load-alternates'
The object database layer has been simplified by eagerly loading
alternate object directories upon initialization, instead of
deferring it to the first object lookup.  This eliminates the need
for scattered lazy-loading calls throughout the codebase and paves
the way for integrating alternates with the pluggable backends.

* ps/odb-eagerly-load-alternates:
  odb: drop `alternates_db` field
  odb: drop `loaded_alternates` field
  odb: eagerly initialize alternates
  odb: decouple source path comparisons from `the_repository`
  setup: create ref and object databases after config is written
2026-08-31 08:24:59 -07:00
Junio C Hamano 189ff3a56d Merge branch 'vm/complete-history'
The command line completion (in contrib/) has been taught to handle
the experimental 'git history' command.

* vm/complete-history:
  completion: complete 'git history split' pathspecs
  completion: complete 'git history --update-refs' values
  completion: complete 'git history --empty' values
  completion: add 'git history' subcommands
2026-08-31 08:24:59 -07:00
Junio C Hamano 6e6f4b582c Merge branch 'ps/odb-generic-corrupt-objects'
The object database (odb) API has been refactored to distinguish
between missing objects and corrupt ones by returning more
descriptive error statuses.  Both the packed and loose backends now
faithfully propagate error details using a generic strbuf error
mechanism, removing backend-specific leakage from central lookup
paths.

* ps/odb-generic-corrupt-objects:
  odb: handle `OBJECT_INFO_DIE_IF_CORRUPT` generically
  odb/source: allow `read_object_info()` to bubble up error messages
  odb/source: let callers discern missing and corrupt objects
  odb/source: introduce error status when reading objects
  odb/source-packed: flag known-bad objects as corrupt and not missing
2026-08-31 08:24:59 -07:00
Junio C Hamano 9321f5936a Merge branch 'yn/worktree-add-no-dwim-with-b'
The DWIM logic in 'git worktree add' sometimes tried to infer a
remote-tracking branch when an explicit '-b' or '-B' option was
given to create a new branch, causing the explicit branch name to
be ignored, which has been corrected.

* yn/worktree-add-no-dwim-with-b:
  worktree add: shouldn't dwim if -b or -B is given
2026-08-31 08:24:58 -07:00
Junio C Hamano c73e85354c The 20th batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-28 11:04:57 -07:00
Junio C Hamano f9a1c7b83b Merge branch 'sk/object-name-use-after-free'
A heap-use-after-free bug in the object name parsing code when
reporting failures with a relative path to a sparse directory has
been corrected.

* sk/object-name-use-after-free:
  object-name: avoid use-after-free in get_oid_with_context_1()
2026-08-28 11:04:57 -07:00
Junio C Hamano 9c94d206f0 Merge branch 'kh/format-rev-doc-synopsis'
The documentation for 'git format-rev' has been updated to use the
[synopsis] block definition on code blocks to properly highlight
placeholders, and a quoting inconsistency in the running text has
been fixed.

* kh/format-rev-doc-synopsis:
  doc: format-rev: use [synopsis] on code block
  doc: format-rev: quote subject placeholder before and after
2026-08-28 11:04:57 -07:00
Junio C Hamano f78ce2f7b6 The 19th batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-25 10:53:34 -07:00
Junio C Hamano fee541a0d8 Merge branch 'jc/complete-checkout'
'git -C <dir> checkout fi<TAB>' did not complete, which has been
corrected.

* jc/complete-checkout:
  completion: 'git checkout' completes untracked paths as a last resort
  completion: complete tracked paths for "git checkout"
  completion: no-op refactoring of checkout completion
2026-08-25 10:53:34 -07:00
Junio C Hamano 4e5713a686 Merge branch 'jc/complete-diff-tracked-paths'
'git -C <dir> diff fi<TAB>' did not complete 'file', which has been
corrected.

* jc/complete-diff-tracked-paths:
  completion: 'git diff' completes untracked paths as a last resort
  completion: complete tracked paths for 'git diff'
  completion: no-op refactoring of diff completion
2026-08-25 10:53:33 -07:00
Junio C Hamano 3caf98a8bf Merge branch 'ch/chdir-notify-drop-name'
The unused name parameter in 'struct chdir_notify_entry' has been
removed from chdir_notify_register(), chdir_notify_unregister(), and
related callback signatures across several subsystems, simplifying the
API now that trace output no longer uses it.

* ch/chdir-notify-drop-name:
  chdir-notify.h: Removed unused param 'name'
2026-08-25 10:53:33 -07:00
Junio C Hamano b7677512b3 Merge branch 'js/packfile-fast-append'
The performance of adding numerous new packfiles has been improved
by introducing a fast path for known-new packfiles to skip an
unnecessary traversal in packfile_list_append(), avoiding a
quadratic complexity regression on load.

* js/packfile-fast-append:
  packfile: fix perf regression with many packs
2026-08-25 10:53:33 -07:00
Junio C Hamano 6d7be5f7fd Merge branch 'ss/submittingpatches-typofix'
Typofix.

* ss/submittingpatches-typofix:
  doc: fix typo in submitting patches
2026-08-25 10:53:32 -07:00
Junio C Hamano 6730f07098 Merge branch 'ss/repack-drop-filtered'
'git repack' has been taught '--drop-filtered' to delete local
promisor blobs exceeding a limit (currently 'blob:limit=') in partial
clones, reclaiming space.  Guards prevent running during other
operations or if referenced by the index.

* ss/repack-drop-filtered:
  builtin/repack: add guards for --drop-filtered
  builtin/repack: actually drop filtered promisor blobs
  builtin/repack: enumerate promisor blobs for --drop-filtered
  repack-promisor: allow excluding objects from the rebuilt promisor pack
  list-objects-filter: add list_objects_filter__filter_oidset()
  builtin/repack: add --drop-filtered and --dry-run options
2026-08-25 10:53:32 -07:00
Junio C Hamano 2c3adbb2c4 The 18th batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-24 13:17:51 -07:00
Junio C Hamano 66573dbe3a Merge branch 'en/diff-l-opt-help'
The help text for the '-l' option of 'git diff' has been updated.

* en/diff-l-opt-help:
  diff: avoid misleading statement about -l option
2026-08-24 13:17:51 -07:00
Junio C Hamano 18ce227f12 Merge branch 'ps/t7900-deflake-maintenance'
Various tests in 't7900-maintenance.sh' have been updated to use a
throwaway repository, and auto-detaching of maintenance tasks is now
disabled for these tests to fix flaky races with concurrent background
maintenance jobs.

* ps/t7900-deflake-maintenance:
  t7900: fix flaky "maintenance.strategy" test
  t7900: adapt some tests to use a throwaway repository
2026-08-24 13:17:51 -07:00
Junio C Hamano bc4c56690e Merge branch 'en/serve-promisor-remote-fix'
A client requesting the promisor-remote capability without a value
caused a null pointer dereference, which has been corrected by
rejecting a request without an argument.

* en/serve-promisor-remote-fix:
  serve: reject valueless promisor-remote capability
2026-08-24 13:17:51 -07:00
Junio C Hamano 781fd4ea83 Merge branch 'js/pack-objects-delta-size-t'
The 'pack-objects' and delta-encoding code paths have been updated to
use 'size_t' instead of 'unsigned long' for object sizes and offset
limits, avoiding potential truncation issues on 64-bit Windows.

* js/pack-objects-delta-size-t:
  packfile: widen `unpack_object_header_buffer()` to `size_t`
  git-zlib: widen `git_deflate_bound()` to `size_t`
  t/helper/test-pack-deltas: widen `do_compress()`'s maxsize local to `size_t`
  http-push: widen `start_put()`'s size local from `ssize_t` to `size_t`
  diff: widen `deflate_it()`'s bound local from int to `size_t`
  archive-zip: widen `zlib_deflate_raw()`'s maxsize local to `size_t`
  packfile, git-zlib: widen `use_pack()` and zstream avail fields to `size_t`
  delta: widen `create_delta()` and `diff_delta()` to `size_t`
  pack-objects: widen `mem_usage` and `try_delta()`'s out-param to `size_t`
  pack-objects: widen `free_unpacked()` return to `size_t`
  pack-objects: widen delta-cache accounting to `size_t`
  delta: widen `create_delta_index()` parameter to `size_t`
  diff-delta: widen `struct delta_index`' size fields to `size_t`
2026-08-24 13:17:51 -07:00
Junio C Hamano 32f49ed9f2 Merge branch 'cc/git-shallow-file-wo-value'
The '--shallow-file' option of 'git' command requires a value, but the
code did not check the presence of a value and instead segfaulted
without one, which has been corrected.

* cc/git-shallow-file-wo-value:
  git: avoid segfault on "git --shallow-file" without a value
2026-08-24 13:17:50 -07:00
Junio C Hamano 15b23b50a6 Merge branch 'en/sequencer-lose-pretty-given'
The setting of a now-unused member '.pretty_given' in the sequencer
machinery has been removed.

* en/sequencer-lose-pretty-given:
  sequencer: remove unnecessary variable setting
2026-08-24 13:17:50 -07:00
Junio C Hamano fcc8c931b5 Merge branch 'js/coverity-unchecked-returns-fix'
A handful of code paths have been corrected to check return values
from functions like curl_easy_duphandle(), deflateInit(), lseek(),
dup(), and strbuf_getline_lf(), resolving several Coverity warnings
about unchecked returns.

* js/coverity-unchecked-returns-fix:
  bisect: handle dup() failure when redirecting stdout
  bisect: check get_terms return at all call sites
  bisect: check strbuf_getline_lf return when reading terms
  transport-helper: warn when export-marks file cannot be finalized
  transport-helper: check dup() return in get_exporter
  compat/pread: check initial lseek for errors
  last-modified: handle repo_parse_commit() failures
  reftable tests: check reftable_table_init_ref_iterator() return
  reftable/block: check deflateInit() return value
  reftable: handle block-writer initialization errors
  config: propagate launch_editor() failure in show_editor()
  http: die on curl_easy_duphandle failure in get_active_slot
2026-08-24 13:17:50 -07:00
Junio C Hamano 593c42fe07 The 17th batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-23 18:01:47 -07:00
Junio C Hamano 679a72c6b8 Merge branch 'kk/merge-base-exhaustion'
The merge-base computation has been optimized by stopping the walk
early when one side's exclusive commits in the queue are exhausted,
yielding significant speedups for queries with one-sided histories.

* kk/merge-base-exhaustion:
  commit-reach: remove commit-date ordering fallback
  commit-reach: move min_generation check into paint_queue_get()
  commit-reach: terminate merge-base walk when one paint side is exhausted
  commit-reach: introduce struct paint_state with per-side counters
  t6600: add clock-skew topologies and step counts for edge cases
  commit-reach: add trace2 instrumentation to paint_down_to_common()
  t6099: add side-exhaustion regression test
  t6600: add test cases for side-exhaustion edge cases
  test-lib-functions: improve diagnostic output for trace2 data assertions
  Documentation/technical: add paint-down-to-common doc
2026-08-23 18:01:46 -07:00
Junio C Hamano e8e7bf97fe Merge branch 'js/sequencer-release-odb-before-commit'
The sequencer has been updated to release the object database before
spawning 'git commit'.  This prevents open file handles from
blocking auto-maintenance tasks, such as repacking, on systems like
Windows where open files cannot be easily unlinked.

* js/sequencer-release-odb-before-commit:
  sequencer: release the ODB before spawning git commit
2026-08-23 18:01:45 -07:00
Junio C Hamano 6aab7b26a6 Merge branch 'hn/send-email-missing-subject-error'
The error message given by 'git send-email' when a message file is
missing a 'Subject:' header has been clarified, and the error string
is now terminated with a newline so that Perl avoids appending its
internal source location data.

* hn/send-email-missing-subject-error:
  send-email: clarify missing subject error
2026-08-23 18:01:44 -07:00
Junio C Hamano a2ef06b1ef Merge branch 'ps/odb-streams'
The 'struct odb_read_stream' and 'struct odb_write_stream'
structures have been consolidated into a single unified 'struct
odb_stream' structure, simplifying object database streaming APIs
and enabling streaming of arbitrary object types.

* ps/odb-streams:
  odb/streaming: unify function names to create new streams
  odb/streaming: rename `struct input_zstream_data`
  odb/streaming: rename `struct read_object_fd_data`
  odb/streaming: consolidate read and write streams
  odb/streaming: rename `struct odb_read_stream`
  odb/streaming: support streaming arbitrary object types
  odb/streaming: drop `is_finished` field
  odb/streaming: track write stream size in the structure
2026-08-23 18:01:43 -07:00
Junio C Hamano 10d3ea2469 Merge branch 'cc/fast-import-usage'
The usage string of 'git fast-import' has been updated to use the
parse_options() API for displaying help, and its SYNOPSIS in the
documentation has been standardized to match.

* cc/fast-import-usage:
  fast-import: remove useless from_stream argument
  fast-import: use parse_options() for command line options
  fast-import: use callbacks to parse some options
  fast-import: use struct option for usage string
  fast-import: move command state globals into 'struct fast_import_state'
  fast-import: introduce 'struct fast_import_state'
  fast-import: factor out option_*() functions
  fast-import: use int for some bool flags
  fast-import: localize 'i' into the 'for' loops using it
  api-parse-options.adoc: document hidden and OPT_*_F option macros
  api-parse-options.adoc: document per-option flags
  parse-options: introduce OPT_HIDDEN_GROUP
2026-08-23 18:01:42 -07:00
Junio C Hamano 4b27b7c707 Merge branch 'ps/cat-file-remote-object-info-type'
The 'remote-object-info' command for 'git cat-file --batch-command'
has been extended to support the '%(objecttype)' placeholder.

* ps/cat-file-remote-object-info-type:
  cat-file: unify default format
  serve: advertise type capability
  fetch-object-info: parse type from server response
  protocol-caps: add type support to object-info
  transport: drop remote object-info fields from transport struct
  fetch-object-info: die() on the remaining error path
  fetch-object-info: use dedicated struct for the results
  fetch-object-info: pass arguments directly instead of a struct
  fetch-object-info: detect malformed server responses
  t5701: use test_file_size() to get the size of a file
2026-08-23 18:01:42 -07:00
Patrick Steinhardt 4e00f13e7e odb/files: be less aggressive with geometric repacking
When performing auto-maintenance with geometric repacking we have two
conditions that may trigger a repack:

  - Either the geometric sequence of packfiles is invalidated.

  - Or we have too many loose objects.

The first condition shouldn't trigger all that often: it may be hit when
we fetch a new packfile, but users tend to not do that all the time. The
second condition is what typically triggers more regularly though, as
every command that ends up writing new objects may cause us to cross the
threshold of loose objects. It is thus preferable to not be too
aggressive here, as otherwise we may end up repacking objects quite
often.

For the geometric-repacking strategy though we have a default of 100
objects, only. As we're approximating the count of objects by only
reading the "objects/17/" shared, we'd only need 2 objects in there
before we perform a repack by default, which is quite aggressive.
git-gc(1) on the other hand has a default of 6700, so it is quite a bit
more conservative here.

Being this aggressive is also causing problems as reported by our users.
When running lots of concurrent writers, those writes will constantly
end up spawning maintenance jobs that end up repacking objects. As we
also prune objects, a concurrently running process that tries to write
an object may see that the sharding directories get removed under their
feet. While we try re-creating such leading directories, we only do so a
single time, and it may happen that the directory vanishes again before
we had the chance to create the loose object. This is not a new problem,
but it is exacerbated by us running maintenance this aggressively.

Improve the status quo by reducing the frequency at which we pack loose
objects to the same frequency that git-gc(1) uses.

Reported-by: Stefan Haller <lists@haller-berlin.de>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-21 10:19:14 -07:00
Patrick Steinhardt 5176dd3d05 bundle: generate packfiles via the object database
git-bundle(1) spawns git-pack-objects(1) directly to generate the pack
data that gets appended to the bundle header. While bundles are not
part of the wire protocol, they are a transfer mechanism for packs all
the same, so convert them to use the pack generation interface of the
object database as well.

This makes the pack generator the single spawn point for all pack
streams that leave the repository, leaving only local maintenance tasks
like git-repack(1) with direct knowledge of git-pack-objects(1).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-21 09:01:55 -07:00
Patrick Steinhardt 9e8558a31d bundle: get (mostly) rid of `the_repository`
Refactor "bundle.c" so that we don't depend on `the_repository` anymore.
This conversion is trivial for most of the part, as we already have a
repository available in all calling conexts.

The only exception is that we use `get_log_output_encoding()`, which
implicitly depends on `the_repository`. Add an `extern` declaration for
this function so that we can drop `USE_THE_REPOSITORY_VARIABLE` and not
accidentally introduce more uses of `the_repository`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-21 09:01:54 -07:00
Patrick Steinhardt 3f0986b27c builtin/bundle: refactor option handling for progress meter
The git-bundle(1) command has a couple of command line options that
relate to whether or not progress should be reported. These options
match the options that git-pack-objects(1) expects, and consequently
they mostly get passed through to it directly.

This results in somewhat of a confusing interface: there are four
different options that relate to whether or not progress should be
displayed and how verbose it should be. But in reality, there's really
only two modes:

  - "--progress" and "--all-progress" result in the same outcome, which
    is also documented as such.

  - "--all-progress-implied" does nothing as we pass that argument to
    git-pack-objects(1) unconditionally anyway.

So in the end, the options only control whether or not progress should
be displayed at all, nothing else.

Refactor the interface to instead use a simple `progress` boolean. This
makes argument handling a lot more straight-forward and it prepares us
for the next commit, where we're migrating git-bundle(1) to the generic
interface for generating a packfile.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-21 09:01:54 -07:00
Patrick Steinhardt 7d2289a23d send-pack: generate packfiles via the object database
When pushing, git-send-pack(1) spawns git-pack-objects(1) directly to
generate the packfile that gets sent to the remote. Same as with
git-upload-pack(1), which has been adapted in the preceding commit,
this hard-codes the assumption that objects can be packed via
git-pack-objects(1), which is specific to the "files" backend.

Convert git-send-pack(1) to use the pack generation interface of the
object database instead.

Note that this requires us to adapt t5516 because the parameters passed
to git-pack-objects(1) are changing:

  - The order of arguments changes.

  - We pass "--quiet" instead of "-q".

  - We don't pass "--all-progress-implied" anymore when not generating
    output.

All of these changes are benign though and should not result in a change
in behaviour.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-21 09:01:54 -07:00