revision.[ch]: document and move code declared around "init"

A subsequent commit will add "REV_INFO_INIT" macro adjacent to repo_init_revisions(), unfortunately between the "struct rev_info" itself and that function we've added various miscellaneous code between the two over the years. Let's move that code either lower in revision.h, giving it API docs while we're at it, or in cases where it wasn't public API at all move it into revision.c No lines of code are changed here, only moved around. The only changes are the addition of new API comments. The "tree_difference" variable could also be declared like this, which I think would be a lot clearer, but let's leave that for now to keep this a move-only change: static enum { REV_TREE_SAME, REV_TREE_NEW, /* Only new files */ REV_TREE_OLD, /* Only files removed */ REV_TREE_DIFFERENT, /* Mixed changes */ } tree_difference = REV_TREE_SAME; Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Apr 13, 2022 at 22:01 UTC 296a1438455d366475570ac49afb466f591417dc
2 files changed +28 -26
revision.c
+4
@@ -606,6 +606,10 @@ static struct commit *one_relevant_parent(const struct rev_info *revs,
606 *
607 * 2. We saw anything except REV_TREE_NEW.
608 */
609 +#define REV_TREE_SAME 0
610 +#define REV_TREE_NEW 1 /* Only new files */
611 +#define REV_TREE_OLD 2 /* Only files removed */
612 +#define REV_TREE_DIFFERENT 3 /* Mixed changes */
613 static int tree_difference = REV_TREE_SAME;
614
615 static void file_add_remove(struct diff_options *options,
revision.h
+24 -26
@@ -329,32 +329,6 @@ struct rev_info {
329 struct tmp_objdir *remerge_objdir;
330 };
331
332 -int ref_excluded(struct string_list *, const char *path);
333 -void clear_ref_exclusion(struct string_list **);
334 -void add_ref_exclusion(struct string_list **, const char *exclude);
335 -
336 -
337 -#define REV_TREE_SAME 0
338 -#define REV_TREE_NEW 1 /* Only new files */
339 -#define REV_TREE_OLD 2 /* Only files removed */
340 -#define REV_TREE_DIFFERENT 3 /* Mixed changes */
341 -
342 -/* revision.c */
343 -typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *);
344 -extern volatile show_early_output_fn_t show_early_output;
345 -
346 -struct setup_revision_opt {
347 - const char *def;
348 - void (*tweak)(struct rev_info *, struct setup_revision_opt *);
349 - unsigned int assume_dashdash:1,
350 - allow_exclude_promisor_objects:1;
351 - unsigned revarg_opt;
352 -};
353 -
354 -#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
355 -#define init_revisions(revs, prefix) repo_init_revisions(the_repository, revs, prefix)
356 -#endif
357 -
332 /**
333 * Initialize a rev_info structure with default values. The third parameter may
334 * be NULL or can be prefix path, and then the `.prefix` variable will be set
@@ -366,6 +340,9 @@ struct setup_revision_opt {
340 void repo_init_revisions(struct repository *r,
341 struct rev_info *revs,
342 const char *prefix);
343 +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
344 +#define init_revisions(revs, prefix) repo_init_revisions(the_repository, revs, prefix)
345 +#endif
346
347 /**
348 * Parse revision information, filling in the `rev_info` structure, and
@@ -374,6 +351,13 @@ void repo_init_revisions(struct repository *r,
351 * head of the argument list. The last parameter is used in case no
352 * parameter given by the first two arguments.
353 */
354 +struct setup_revision_opt {
355 + const char *def;
356 + void (*tweak)(struct rev_info *, struct setup_revision_opt *);
357 + unsigned int assume_dashdash:1,
358 + allow_exclude_promisor_objects:1;
359 + unsigned revarg_opt;
360 +};
361 int setup_revisions(int argc, const char **argv, struct rev_info *revs,
362 struct setup_revision_opt *);
363
@@ -423,6 +407,14 @@ void mark_trees_uninteresting_sparse(struct repository *r, struct oidset *trees)
407
408 void show_object_with_name(FILE *, struct object *, const char *);
409
410 +/**
411 + * Helpers to check if a "struct string_list" item matches with
412 + * wildmatch().
413 + */
414 +int ref_excluded(struct string_list *, const char *path);
415 +void clear_ref_exclusion(struct string_list **);
416 +void add_ref_exclusion(struct string_list **, const char *exclude);
417 +
418 /**
419 * This function can be used if you want to add commit objects as revision
420 * information. You can use the `UNINTERESTING` object flag to indicate if
@@ -478,4 +470,10 @@ int rewrite_parents(struct rev_info *revs,
470 */
471 struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit);
472
473 +/**
474 + * Global for the (undocumented) "--early-output" flag for "git log".
475 + */
476 +typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *);
477 +extern volatile show_early_output_fn_t show_early_output;
478 +
479 #endif