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: 2f8c3f6
Choose a base ref
...
head repository: git/git
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 83869e1
Choose a head ref
  • 16 commits
  • 26 files changed
  • 3 contributors

Commits on Mar 20, 2026

  1. object-file: fix sparse 'plain integer as NULL pointer' error

    Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    ramsay-jones authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    736cef8 View commit details
    Browse the repository at this point in the history
  2. Merge branch 'ps/object-counting' into ps/odb-generic-object-name-han…

    …dling
    
    * ps/object-counting:
      object-file: fix sparse 'plain integer as NULL pointer' error
      odb: introduce generic object counting
      odb/source: introduce generic object counting
      object-file: generalize counting objects
      object-file: extract logic to approximate object count
      packfile: extract logic to count number of objects
      odb: stop including "odb/source.h"
    gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    7f75767 View commit details
    Browse the repository at this point in the history
  3. oidtree: modernize the code a bit

    The "oidtree.c" subsystem is rather small and self-contained and tends
    to just work. It thus doesn't typically receive a lot of attention,
    which has as a consequence that it's coding style is somewhat dated
    nowadays.
    
    Modernize the style of this subsystem a bit:
    
      - Rename the `oidtree_iter()` function to `oidtree_each_cb()`.
    
      - Rename `struct oidtree_iter_data` to `struct oidtree_each_data` to
        match the renamed callback function type.
    
      - Rename parameters and variables to clarify their intent.
    
      - Add comments that explain what some of the functions do.
    
      - Adapt the return value of `oidtree_contains()` to be a boolean.
    
    This prepares for some changes to the subsystem that'll happen in the
    next commit.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    1382e54 View commit details
    Browse the repository at this point in the history
  4. oidtree: extend iteration to allow for arbitrary return codes

    The interface `cb_each()` iterates through a crit-bit tree and calls a
    specific callback function for each of the contained items. The callback
    function is expected to return either:
    
      - `CB_CONTINUE` in case iteration shall continue.
    
      - `CB_BREAK` to abort iteration.
    
    This is needlessly restrictive though, as callers may want to return
    arbitrary values and have them be bubbled up to the `cb_each()` call
    site. In fact, this is a rather common pattern we have: whenever such a
    callback function returns a non-zero error code, we abort iteration and
    bubble up the code as-is.
    
    Refactor both the crit-bit tree and oidtree subsystems to behave
    accordingly.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    fe446b0 View commit details
    Browse the repository at this point in the history
  5. odb: introduce struct odb_for_each_object_options

    The `odb_for_each_object()` function only accepts a bitset of flags. In
    a subsequent commit we'll want to change object iteration to also
    support iterating over only those objects that have a specific prefix.
    While we could of course add the prefix to the function signature, or
    alternatively introduce a new function, both of these options don't
    really seem to be that sensible.
    
    Instead, introduce a new `struct odb_for_each_object_options` that can
    be passed to a new `odb_for_each_object_ext()` function. Splice through
    the options structure into the respective object database sources.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    cfd575f View commit details
    Browse the repository at this point in the history
  6. object-name: move logic to iterate through loose prefixed objects

    The logic to iterate through loose objects that have a certain prefix is
    currently hosted in "object-name.c". This logic reaches into specifics
    of the loose object source, so it breaks once a different backend is
    used for the object storage.
    
    Move the logic to iterate through loose objects with a prefix into
    "object-file.c". This is done by extending the for-each-object options
    to support an optional prefix that is then honored by the loose source.
    Naturally, we'll also have this support in the packfile store. This is
    done in the next commit.
    
    Furthermore, there are no users of the loose cache outside of
    "object-file.c" anymore. As such, convert `odb_source_loose_cache()` to
    have file scope.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    284b786 View commit details
    Browse the repository at this point in the history
  7. object-name: move logic to iterate through packed prefixed objects

    Similar to the preceding commit, move the logic to iterate through
    objects that have a given prefix into "packfile.c".
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    e30bff8 View commit details
    Browse the repository at this point in the history
  8. object-name: extract function to parse object ID prefixes

    Extract the logic that parses an object ID prefix into a new function.
    This function will be used by a second callsite in a subsequent commit.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    28c9254 View commit details
    Browse the repository at this point in the history
  9. object-name: backend-generic repo_collect_ambiguous()

    The function `repo_collect_ambiguous()` is responsible for collecting
    objects whose IDs match a specific prefix. The information is then
    used to inform the user about which objects they could have meant in
    case a short object ID is ambiguous.
    
    The logic to do this uses the object disambiguation infrastructure and
    calls into backend-specific functions to iterate through loose and
    packed objects. This isn't really required anymore though: all we want
    to do is to enumerate objects that have such a prefix and then append
    those objects to a `struct oid_array`. This can be trivially achieved
    in a generic way now that `odb_for_each_object()` has learned to yield
    only objects that match such a prefix.
    
    Refactor the code to use the backend-generic infrastructure instead.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    d2612fe View commit details
    Browse the repository at this point in the history
  10. object-name: backend-generic get_short_oid()

    The function `get_short_oid()` takes as input an abbreviated object ID
    and tries to turn that object ID into the full object ID. This is done
    by iterating through all objects that have the user-provided prefix. If
    that yields exactly one object we know that the abbreviated object ID is
    unambiguous, otherwise it is ambiguous and we print the list of objects
    that match the prefix.
    
    We iterate through all objects with the given prefix by calling both
    `find_short_packed_object()` and `find_short_object_filename()`, which
    is of course specific to the "files" backend. But we now have a generic
    way to iterate through objects with a specific prefix.
    
    Refactor the code to use `odb_for_each_object()` instead so that it
    works with object backends different than the "files" backend.
    
    Remove the now-unused `find_short_packed_object()` function.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    eac58de View commit details
    Browse the repository at this point in the history
  11. object-name: merge update_candidates() and match_prefix()

    There's only a single callsite for `match_prefix()`, and that function
    is a rather trivial wrapper of `update_candidates()`. Merge these two
    functions into a single `update_disambiguate_state()` function.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    e9b7caa View commit details
    Browse the repository at this point in the history
  12. object-name: abbreviate loose object names without disambiguate_state

    The function `find_short_object_filename()` takes an object ID and
    computes the minimum required object name length to make it unique. This
    is done by reusing the object disambiguation infrastructure, where we
    iterate through every loose object and then update the disambiguate
    state one by one.
    
    Ultimately, we don't care about the disambiguate state though. It is
    used because this infrastructure knows how to enumerate only those
    objects that match a given prefix. But now that we have extended the
    `odb_for_each_object()` function to do this for us we have an easier way
    to do this. Consequently, we really only use the disambiguate state now
    to propagate `struct min_abbrev_data`.
    
    Refactor the code and drop this indirection so that we use `struct
    min_abbrev_data` directly. This also allows us to drop some now-unused
    logic from the disambiguate infrastructure.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    67f47ea View commit details
    Browse the repository at this point in the history
  13. object-name: simplify computing common prefixes

    The function `extend_abbrev_len()` computes the length of common hex
    characters between two object IDs. This is done by:
    
      - Making the caller provide the `hex` string for the needle object ID.
    
      - Comparing every hex position of the haystack object ID with
        `get_hex_char_from_oid()`.
    
    Turning the binary representation into hex first is roundabout though:
    we can simply compare the binary representation and give some special
    attention to the final nibble.
    
    Introduce a new function `oid_common_prefix_hexlen()` that does exactly
    this and refactor the code to use the new function. This allows us to
    drop the `struct min_abbrev_data::hex` field. Furthermore, this function
    will be used in by some other callsites in subsequent commits.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    1a2842d View commit details
    Browse the repository at this point in the history
  14. object-name: move logic to compute loose abbreviation length

    The function `repo_find_unique_abbrev_r()` takes as input an object ID
    as well as a minimum object ID length and returns the minimum required
    prefix to make the object ID unique.
    
    The logic that computes the abbreviation length for loose objects is
    deeply tied to the loose object storage format. As such, it would fail
    in case a different object storage format was used.
    
    Prepare for making this logic generic to the backend by moving the logic
    into a new `odb_source_loose_find_abbrev_len()` function that is part of
    "object-file.c".
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    ab3ab10 View commit details
    Browse the repository at this point in the history
  15. object-file: move logic to compute packed abbreviation length

    Same as the preceding commit, move the logic that computes the minimum
    required prefix length to make a given object ID unique for the packfile
    store into a new function `packfile_store_find_abbrev_len()` that is
    part of "packfile.c". This prepares for making the logic fully generic
    via pluggable object databases.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    6c2ede6 View commit details
    Browse the repository at this point in the history
  16. odb: introduce generic odb_find_abbrev_len()

    Introduce a new generic `odb_find_abbrev_len()` function as well as
    source-specific callback functions. This makes the logic to compute the
    required prefix length to make a given object unique fully pluggable.
    
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    pks-t authored and gitster committed Mar 20, 2026
    Configuration menu
    Copy the full SHA
    83869e1 View commit details
    Browse the repository at this point in the history
Loading