mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
![Taylor Blau](/assets/img/avatar_default.png)
A future caller will want to be able to perform a reachability traversal which terminates when visiting an object found in a kept pack. The closest existing option is '--honor-pack-keep', but this isn't quite what we want. Instead of halting the traversal midway through, a full traversal is always performed, and the results are only trimmed afterwords. Besides needing to introduce a new flag (since culling results post-facto can be different than halting the traversal as it's happening), there is an additional wrinkle handling the distinction in-core and on-disk kept packs. That is: what kinds of kept pack should stop the traversal? Introduce '--no-kept-objects[=<on-disk|in-core>]' to specify which kinds of kept packs, if any, should stop a traversal. This can be useful for callers that want to perform a reachability analysis, but want to leave certain packs alone (for e.g., when doing a geometric repack that has some "large" packs which are kept in-core that it wants to leave alone). Note that this option is not guaranteed to produce exactly the set of objects that aren't in kept packs, since it's possible the traversal order may end up in a situation where a non-kept ancestor was "cut off" by a kept object (at which point we would stop traversing). But, we don't care about absolute correctness here, since this will eventually be used as a purely additive guide in an upcoming new repack mode. Explicitly avoid documenting this new flag, since it is only used internally. In theory we could avoid even adding it rev-list, but being able to spell this option out on the command-line makes some special cases easier to test without promising to keep it behaving consistently forever. Those tricky cases are exercised in t6114. Signed-off-by: Taylor Blau <me@ttaylorr.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
70 lines
1.7 KiB
Bash
Executable file
70 lines
1.7 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='rev-list with .keep packs'
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
test_commit loose &&
|
|
test_commit packed &&
|
|
test_commit kept &&
|
|
|
|
KEPT_PACK=$(git pack-objects --revs .git/objects/pack/pack <<-EOF
|
|
refs/tags/kept
|
|
^refs/tags/packed
|
|
EOF
|
|
) &&
|
|
MISC_PACK=$(git pack-objects --revs .git/objects/pack/pack <<-EOF
|
|
refs/tags/packed
|
|
^refs/tags/loose
|
|
EOF
|
|
) &&
|
|
|
|
touch .git/objects/pack/pack-$KEPT_PACK.keep
|
|
'
|
|
|
|
rev_list_objects () {
|
|
git rev-list "$@" >out &&
|
|
sort out
|
|
}
|
|
|
|
idx_objects () {
|
|
git show-index <$1 >expect-idx &&
|
|
cut -d" " -f2 <expect-idx | sort
|
|
}
|
|
|
|
test_expect_success '--no-kept-objects excludes trees and blobs in .keep packs' '
|
|
rev_list_objects --objects --all --no-object-names >kept &&
|
|
rev_list_objects --objects --all --no-object-names --no-kept-objects >no-kept &&
|
|
|
|
idx_objects .git/objects/pack/pack-$KEPT_PACK.idx >expect &&
|
|
comm -3 kept no-kept >actual &&
|
|
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success '--no-kept-objects excludes kept non-MIDX object' '
|
|
test_config core.multiPackIndex true &&
|
|
|
|
# Create a pack with just the commit object in pack, and do not mark it
|
|
# as kept (even though it appears in $KEPT_PACK, which does have a .keep
|
|
# file).
|
|
MIDX_PACK=$(git pack-objects .git/objects/pack/pack <<-EOF
|
|
$(git rev-parse kept)
|
|
EOF
|
|
) &&
|
|
|
|
# Write a MIDX containing all packs, but use the version of the commit
|
|
# at "kept" in a non-kept pack by touching $MIDX_PACK.
|
|
touch .git/objects/pack/pack-$MIDX_PACK.pack &&
|
|
git multi-pack-index write &&
|
|
|
|
rev_list_objects --objects --no-object-names --no-kept-objects HEAD >actual &&
|
|
(
|
|
idx_objects .git/objects/pack/pack-$MISC_PACK.idx &&
|
|
git rev-list --objects --no-object-names refs/tags/loose
|
|
) | sort >expect &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_done
|