Git fork

list-objects: consolidate traverse_commit_list[_filtered]

Now that all consumers of traverse_commit_list_filtered() populate the
'filter' member of 'struct rev_info', we can drop that parameter from
the method prototype to simplify things. In addition, the only thing
different now between traverse_commit_list_filtered() and
traverse_commit_list() is the presence of the 'omitted' parameter, which
is only non-NULL for one caller. We can consolidate these two methods by
having one call the other and use the simpler form everywhere the
'omitted' parameter would be NULL.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Derrick Stolee and committed by
Junio C Hamano
3e0370a8 09d4a79e

+29 -31
+3 -3
builtin/pack-objects.c
··· 3778 3778 3779 3779 if (!fn_show_object) 3780 3780 fn_show_object = show_object; 3781 - traverse_commit_list_filtered(&revs.filter, &revs, 3782 - show_commit, fn_show_object, NULL, 3783 - NULL); 3781 + traverse_commit_list(&revs, 3782 + show_commit, fn_show_object, 3783 + NULL); 3784 3784 3785 3785 if (unpack_unreachable_expiration) { 3786 3786 revs.ignore_missing_links = 1;
+1 -1
builtin/rev-list.c
··· 729 729 oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE); 730 730 731 731 traverse_commit_list_filtered( 732 - &revs.filter, &revs, show_commit, show_object, &info, 732 + &revs, show_commit, show_object, &info, 733 733 (arg_print_omitted ? &omitted_objects : NULL)); 734 734 735 735 if (arg_print_omitted) {
+12 -22
list-objects.c
··· 416 416 strbuf_release(&csp); 417 417 } 418 418 419 - void traverse_commit_list(struct rev_info *revs, 420 - show_commit_fn show_commit, 421 - show_object_fn show_object, 422 - void *show_data) 423 - { 424 - struct traversal_context ctx; 425 - ctx.revs = revs; 426 - ctx.show_commit = show_commit; 427 - ctx.show_object = show_object; 428 - ctx.show_data = show_data; 429 - ctx.filter = NULL; 430 - do_traverse(&ctx); 431 - } 432 - 433 419 void traverse_commit_list_filtered( 434 - struct list_objects_filter_options *filter_options, 435 420 struct rev_info *revs, 436 421 show_commit_fn show_commit, 437 422 show_object_fn show_object, 438 423 void *show_data, 439 424 struct oidset *omitted) 440 425 { 441 - struct traversal_context ctx; 426 + struct traversal_context ctx = { 427 + .revs = revs, 428 + .show_object = show_object, 429 + .show_commit = show_commit, 430 + .show_data = show_data, 431 + }; 442 432 443 - ctx.revs = revs; 444 - ctx.show_object = show_object; 445 - ctx.show_commit = show_commit; 446 - ctx.show_data = show_data; 447 - ctx.filter = list_objects_filter__init(omitted, filter_options); 433 + if (revs->filter.choice) 434 + ctx.filter = list_objects_filter__init(omitted, &revs->filter); 435 + 448 436 do_traverse(&ctx); 449 - list_objects_filter__free(ctx.filter); 437 + 438 + if (ctx.filter) 439 + list_objects_filter__free(ctx.filter); 450 440 }
+10 -2
list-objects.h
··· 7 7 8 8 typedef void (*show_commit_fn)(struct commit *, void *); 9 9 typedef void (*show_object_fn)(struct object *, const char *, void *); 10 - void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, void *); 11 10 12 11 typedef void (*show_edge_fn)(struct commit *); 13 12 void mark_edges_uninteresting(struct rev_info *revs, ··· 18 17 struct list_objects_filter_options; 19 18 20 19 void traverse_commit_list_filtered( 21 - struct list_objects_filter_options *filter_options, 22 20 struct rev_info *revs, 23 21 show_commit_fn show_commit, 24 22 show_object_fn show_object, 25 23 void *show_data, 26 24 struct oidset *omitted); 25 + 26 + static inline void traverse_commit_list( 27 + struct rev_info *revs, 28 + show_commit_fn show_commit, 29 + show_object_fn show_object, 30 + void *show_data) 31 + { 32 + traverse_commit_list_filtered(revs, show_commit, 33 + show_object, show_data, NULL); 34 + } 27 35 28 36 #endif /* LIST_OBJECTS_H */
+3 -3
pack-bitmap.c
··· 822 822 show_data.bitmap_git = bitmap_git; 823 823 show_data.base = base; 824 824 825 - traverse_commit_list_filtered(&revs->filter, revs, 826 - show_commit, show_object, 827 - &show_data, NULL); 825 + traverse_commit_list(revs, 826 + show_commit, show_object, 827 + &show_data); 828 828 829 829 revs->include_check = NULL; 830 830 revs->include_check_obj = NULL;