@@ -210,13 +210,14 @@ We'll also need to include the `config.h` header:
210
210
211
211
...
212
212
213
- static int git_walken_config(const char *var, const char *value, void *cb)
213
+ static int git_walken_config(const char *var, const char *value,
214
+ const struct config_context *ctx, void *cb)
214
215
{
215
216
/*
216
217
* For now, we don't have any custom configuration, so fall back to
217
218
* the default config.
218
219
*/
219
- return git_default_config(var, value, cb);
220
+ return git_default_config(var, value, ctx, cb);
220
221
}
221
222
----
222
223
@@ -389,10 +390,11 @@ modifying `rev_info.grep_filter`, which is a `struct grep_opt`.
389
390
First some setup. Add `grep_config()` to `git_walken_config()`:
390
391
391
392
----
392
- static int git_walken_config(const char *var, const char *value, void *cb)
393
+ static int git_walken_config(const char *var, const char *value,
394
+ const struct config_context *ctx, void *cb)
393
395
{
394
- grep_config(var, value, cb);
395
- return git_default_config(var, value, cb);
396
+ grep_config(var, value, ctx, cb);
397
+ return git_default_config(var, value, ctx, cb);
396
398
}
397
399
----
398
400
@@ -523,7 +525,7 @@ about each one.
523
525
524
526
We can base our work on an example. `git pack-objects` prepares all kinds of
525
527
objects for packing into a bitmap or packfile. The work we are interested in
526
- resides in `builtins /pack-objects.c:get_object_list()`; examination of that
528
+ resides in `builtin /pack-objects.c:get_object_list()`; examination of that
527
529
function shows that the all-object walk is being performed by
528
530
`traverse_commit_list()` or `traverse_commit_list_filtered()`. Those two
529
531
functions reside in `list-objects.c`; examining the source shows that, despite
@@ -732,8 +734,8 @@ walk we've just performed:
732
734
} else {
733
735
trace_printf(
734
736
_("Filtered object walk with filterspec 'tree:1'.\n"));
735
- CALLOC_ARRAY(rev->filter, 1);
736
- parse_list_objects_filter(rev->filter, "tree:1");
737
+
738
+ parse_list_objects_filter(& rev->filter, "tree:1");
737
739
}
738
740
traverse_commit_list(rev, walken_show_commit,
739
741
walken_show_object, NULL);
@@ -752,10 +754,12 @@ points to the same tree object as its grandparent.)
752
754
=== Counting Omitted Objects
753
755
754
756
We also have the capability to enumerate all objects which were omitted by a
755
- filter, like with `git log --filter=<spec> --filter-print-omitted`. Asking
756
- `traverse_commit_list_filtered()` to populate the `omitted` list means that our
757
- object walk does not perform any better than an unfiltered object walk; all
758
- reachable objects are walked in order to populate the list.
757
+ filter, like with `git log --filter=<spec> --filter-print-omitted`. To do this,
758
+ change `traverse_commit_list()` to `traverse_commit_list_filtered()`, which is
759
+ able to populate an `omitted` list. Asking for this list of filtered objects
760
+ may cause performance degradations, however, because in this case, despite
761
+ filtering objects, the possibly much larger set of all reachable objects must
762
+ be processed in order to populate that list.
759
763
760
764
First, add the `struct oidset` and related items we will use to iterate it:
761
765
@@ -776,8 +780,9 @@ static void walken_object_walk(
776
780
...
777
781
----
778
782
779
- Modify the call to `traverse_commit_list_filtered()` to include your `omitted`
780
- object:
783
+ Replace the call to `traverse_commit_list()` with
784
+ `traverse_commit_list_filtered()` and pass a pointer to the `omitted` oidset
785
+ defined and initialized above:
781
786
782
787
----
783
788
...
@@ -843,7 +848,7 @@ those lines without having to recompile.
843
848
With only that change, run again (but save yourself some scrollback):
844
849
845
850
----
846
- $ GIT_TRACE=1 ./bin-wrappers/git walken | head -n 10
851
+ $ GIT_TRACE=1 ./bin-wrappers/git walken 2>&1 | head -n 10
847
852
----
848
853
849
854
Take a look at the top commit with `git show` and the object ID you printed; it
@@ -871,7 +876,7 @@ of the first handful:
871
876
872
877
----
873
878
$ make
874
- $ GIT_TRACE=1 ./bin-wrappers git walken | tail -n 10
879
+ $ GIT_TRACE=1 ./bin-wrappers/ git walken 2>&1 | tail -n 10
875
880
----
876
881
877
882
The last commit object given should have the same OID as the one we saw at the
0 commit comments