forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add path walk API and its use in 'git pack-objects' #5171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
derrickstolee
merged 14 commits into
git-for-windows:main
from
derrickstolee:path-walk-on-full
Sep 25, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bd4446e
path-walk: introduce an object walk by path
derrickstolee ce11b59
t6601: add helper for testing path-walk API
derrickstolee c76e9e7
path-walk: allow consumer to specify object types
derrickstolee 7a85f9a
path-walk: allow visiting tags
derrickstolee 0ab378d
revision: create mark_trees_uninteresting_dense()
derrickstolee ac60e11
path-walk: add prune_all_uninteresting option
derrickstolee fda0d77
pack-objects: extract should_attempt_deltas()
derrickstolee 318fd94
pack-objects: add --path-walk option
derrickstolee 9d7c5cb
pack-objects: introduce GIT_TEST_PACK_PATH_WALK
derrickstolee c417efb
repack: add --path-walk option
derrickstolee ebc52fc
pack-objects: enable --path-walk via config
derrickstolee f3c46f9
scalar: enable path-walk during push via config
derrickstolee 940c8a2
pack-objects: refactor path-walk delta phase
derrickstolee d9fc474
pack-objects: thread the path-based compression
derrickstolee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Path-Walk API | ||
============= | ||
|
||
The path-walk API is used to walk reachable objects, but to visit objects | ||
in batches based on a common path they appear in, or by type. | ||
|
||
For example, all reachable commits are visited in a group. All tags are | ||
visited in a group. Then, all root trees are visited. At some point, all | ||
blobs reachable via a path `my/dir/to/A` are visited. When there are | ||
multiple paths possible to reach the same object, then only one of those | ||
paths is used to visit the object. | ||
|
||
When walking a range of commits with some `UNINTERESTING` objects, the | ||
objects with the `UNINTERESTING` flag are included in these batches. In | ||
order to walk `UNINTERESTING` objects, the `--boundary` option must be | ||
used in the commit walk in order to visit `UNINTERESTING` commits. | ||
|
||
Basics | ||
------ | ||
|
||
To use the path-walk API, include `path-walk.h` and call | ||
`walk_objects_by_path()` with a customized `path_walk_info` struct. The | ||
struct is used to set all of the options for how the walk should proceed. | ||
Let's dig into the different options and their use. | ||
|
||
`path_fn` and `path_fn_data`:: | ||
The most important option is the `path_fn` option, which is a | ||
function pointer to the callback that can execute logic on the | ||
object IDs for objects grouped by type and path. This function | ||
also receives a `data` value that corresponds to the | ||
`path_fn_data` member, for providing custom data structures to | ||
this callback function. | ||
|
||
`revs`:: | ||
To configure the exact details of the reachable set of objects, | ||
use the `revs` member and initialize it using the revision | ||
machinery in `revision.h`. Initialize `revs` using calls such as | ||
`setup_revisions()` or `parse_revision_opt()`. Do not call | ||
`prepare_revision_walk()`, as that will be called within | ||
`walk_objects_by_path()`. | ||
+ | ||
It is also important that you do not specify the `--objects` flag for the | ||
`revs` struct. The revision walk should only be used to walk commits, and | ||
the objects will be walked in a separate way based on those starting | ||
commits. | ||
+ | ||
If you want the path-walk API to emit `UNINTERESTING` objects based on the | ||
commit walk's boundary, be sure to set `revs.boundary` so the boundary | ||
commits are emitted. | ||
|
||
`commits`, `blobs`, `trees`, `tags`:: | ||
By default, these members are enabled and signal that the path-walk | ||
API should call the `path_fn` on objects of these types. Specialized | ||
applications could disable some options to make it simpler to walk | ||
the objects or to have fewer calls to `path_fn`. | ||
+ | ||
While it is possible to walk only commits in this way, consumers would be | ||
better off using the revision walk API instead. | ||
|
||
`prune_all_uninteresting`:: | ||
By default, all reachable paths are emitted by the path-walk API. | ||
This option allows consumers to declare that they are not | ||
interested in paths where all included objects are marked with the | ||
`UNINTERESTING` flag. This requires using the `boundary` option in | ||
the revision walk so that the walk emits commits marked with the | ||
`UNINTERESTING` flag. | ||
|
||
Examples | ||
-------- | ||
|
||
See example usages in: | ||
`t/helper/test-path-walk.c`, | ||
`builtin/pack-objects.c` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.