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: e53598a5ab745fb633dc99ed11cbe4b1bee066fa
Choose a base ref
...
head repository: git/git
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 91badeba32d31d4dcc695a8888e5b697b4c3d90c
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 24, 2022

  1. builtin/repack.c: pass "out" to prepare_pack_objects

    `builtin/repack.c`'s `prepare_pack_objects()` is used to prepare a set
    of arguments to a `pack-objects` process which will generate a desired
    pack.
    
    A future patch will add an `--expire-to` option which allows `git
    repack` to write a cruft pack containing the pruned objects out to a
    separate repository. Prepare for this by teaching that function to write
    packs to an arbitrary location specified by the caller.
    
    All existing callers of `prepare_pack_objects()` will pass `packtmp` for
    `out`, retaining the existing behavior.
    
    Signed-off-by: Taylor Blau <[email protected]>
    Signed-off-by: Junio C Hamano <[email protected]>
    ttaylorr authored and gitster committed Oct 24, 2022
    Configuration menu
    Copy the full SHA
    4e7b65b View commit details
    Browse the repository at this point in the history
  2. builtin/repack.c: pass "cruft_expiration" to write_cruft_pack

    `builtin/repack.c`'s `write_cruft_pack()` is used to generate the cruft
    pack when `--cruft` is supplied. It uses a static variable
    "cruft_expiration" which is filled in by option parsing.
    
    A future patch will add an `--expire-to` option which allows `git
    repack` to write a cruft pack containing the pruned objects out to a
    separate repository. In order to implement this functionality, some
    callers will have to pass a value for `cruft_expiration` different than
    the one filled out by option parsing.
    
    Prepare for this by teaching `write_cruft_pack` to take a
    "cruft_expiration" parameter, instead of reading a single static
    variable.
    
    The (sole) existing caller of `write_cruft_pack()` will pass the value
    for "cruft_expiration" filled in by option parsing, retaining existing
    behavior. This means that we can make the variable local to
    `cmd_repack()`, and eliminate the static declaration.
    
    Signed-off-by: Taylor Blau <[email protected]>
    Signed-off-by: Junio C Hamano <[email protected]>
    ttaylorr authored and gitster committed Oct 24, 2022
    Configuration menu
    Copy the full SHA
    eddad36 View commit details
    Browse the repository at this point in the history
  3. builtin/repack.c: write cruft packs to arbitrary locations

    In the following commit, a new write_cruft_pack() caller will be added
    which wants to write a cruft pack to an arbitrary location. Prepare for
    this by adding a parameter which controls the destination of the cruft
    pack.
    
    For now, provide "packtmp" so that this commit does not change any
    behavior.
    
    Signed-off-by: Taylor Blau <[email protected]>
    Signed-off-by: Junio C Hamano <[email protected]>
    ttaylorr authored and gitster committed Oct 24, 2022
    Configuration menu
    Copy the full SHA
    c12cda4 View commit details
    Browse the repository at this point in the history
  4. builtin/repack.c: implement --expire-to for storing pruned objects

    When pruning objects with `--cruft`, `git repack` offers some
    flexibility when selecting the set of which objects are pruned via the
    `--cruft-expiration` option.
    
    This is useful for expiring objects which are older than the grace
    period, making races where to-be-pruned objects become reachable and
    then ancestors of freshly pushed objects, leaving the repository in a
    corrupt state after pruning substantially less likely [1].
    
    But in practice, such races are impossible to avoid entirely, no matter
    how long the grace period is. To prevent this race, it is often
    advisable to temporarily put a repository into a read-only state. But in
    practice, this is not always practical, and so some middle ground would
    be nice.
    
    This patch introduces a new option, `--expire-to`, which teaches `git
    repack` to write an additional cruft pack containing just the objects
    which were pruned from the repository. The caller can specify a
    directory outside of the current repository as the destination for this
    second cruft pack.
    
    This makes it possible to prune objects from a repository, while still
    holding onto a supplemental copy of them outside of the original
    repository. Having this copy on-disk makes it substantially easier to
    recover objects when the aforementioned race is encountered.
    
    `--expire-to` is implemented in a somewhat convoluted manner, which is
    to take advantage of the fact that the first time `write_cruft_pack()`
    is called, it adds the name of the cruft pack to the `names` string
    list. That means the second time we call `write_cruft_pack()`, objects
    in the previously-written cruft pack will be excluded.
    
    As long as the caller ensures that no objects are expired during the
    second pass, this is sufficient to generate a cruft pack containing all
    objects which don't appear in any of the new packs written by `git
    repack`, including the cruft pack. In other words, all of the objects
    which are about to be pruned from the repository.
    
    It is important to note that the destination in `--expire-to` does not
    necessarily need to be a Git repository (though it can be) Notably, the
    expired packs do not contain all ancestors of expired objects. So if the
    source repository contains something like:
    
                  <unreachable>
                 /
        C1 --- C2
          \
           refs/heads/master
    
    where C2 is unreachable, but has a parent (C1) which is reachable, and
    C2 would be pruned, then the expiry pack will contain only C2, not C1.
    
    [1]: https://lore.kernel.org/git/[email protected]/
    
    Signed-off-by: Taylor Blau <[email protected]>
    Signed-off-by: Junio C Hamano <[email protected]>
    ttaylorr authored and gitster committed Oct 24, 2022
    Configuration menu
    Copy the full SHA
    91badeb View commit details
    Browse the repository at this point in the history
Loading