Skip to content

Commit 296a143

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2108fe4 commit 296a143

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

revision.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,10 @@ static struct commit *one_relevant_parent(const struct rev_info *revs,
606606
*
607607
* 2. We saw anything except REV_TREE_NEW.
608608
*/
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 */
609613
static int tree_difference = REV_TREE_SAME;
610614

611615
static void file_add_remove(struct diff_options *options,

revision.h

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -329,32 +329,6 @@ struct rev_info {
329329
struct tmp_objdir *remerge_objdir;
330330
};
331331

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-
358332
/**
359333
* Initialize a rev_info structure with default values. The third parameter may
360334
* be NULL or can be prefix path, and then the `.prefix` variable will be set
@@ -366,6 +340,9 @@ struct setup_revision_opt {
366340
void repo_init_revisions(struct repository *r,
367341
struct rev_info *revs,
368342
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
369346

370347
/**
371348
* Parse revision information, filling in the `rev_info` structure, and
@@ -374,6 +351,13 @@ void repo_init_revisions(struct repository *r,
374351
* head of the argument list. The last parameter is used in case no
375352
* parameter given by the first two arguments.
376353
*/
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+
};
377361
int setup_revisions(int argc, const char **argv, struct rev_info *revs,
378362
struct setup_revision_opt *);
379363

@@ -423,6 +407,14 @@ void mark_trees_uninteresting_sparse(struct repository *r, struct oidset *trees)
423407

424408
void show_object_with_name(FILE *, struct object *, const char *);
425409

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+
426418
/**
427419
* This function can be used if you want to add commit objects as revision
428420
* information. You can use the `UNINTERESTING` object flag to indicate if
@@ -478,4 +470,10 @@ int rewrite_parents(struct rev_info *revs,
478470
*/
479471
struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit);
480472

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+
481479
#endif

0 commit comments

Comments
 (0)