9
9
#include "diff.h"
10
10
#include "commit-slab-decl.h"
11
11
12
+ /**
13
+ * The revision walking API offers functions to build a list of revisions
14
+ * and then iterate over that list.
15
+ *
16
+ * Calling sequence
17
+ * ----------------
18
+ *
19
+ * The walking API has a given calling sequence: first you need to initialize
20
+ * a rev_info structure, then add revisions to control what kind of revision
21
+ * list do you want to get, finally you can iterate over the revision list.
22
+ *
23
+ */
24
+
12
25
/* Remember to update object flag allocation in object.h */
13
26
#define SEEN (1u<<0)
14
27
#define UNINTERESTING (1u<<1)
@@ -306,11 +319,29 @@ struct setup_revision_opt {
306
319
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
307
320
#define init_revisions (revs , prefix ) repo_init_revisions(the_repository, revs, prefix)
308
321
#endif
322
+
323
+ /**
324
+ * Initialize a rev_info structure with default values. The third parameter may
325
+ * be NULL or can be prefix path, and then the `.prefix` variable will be set
326
+ * to it. This is typically the first function you want to call when you want
327
+ * to deal with a revision list. After calling this function, you are free to
328
+ * customize options, like set `.ignore_merges` to 0 if you don't want to
329
+ * ignore merges, and so on.
330
+ */
309
331
void repo_init_revisions (struct repository * r ,
310
332
struct rev_info * revs ,
311
333
const char * prefix );
334
+
335
+ /**
336
+ * Parse revision information, filling in the `rev_info` structure, and
337
+ * removing the used arguments from the argument list. Returns the number
338
+ * of arguments left that weren't recognized, which are also moved to the
339
+ * head of the argument list. The last parameter is used in case no
340
+ * parameter given by the first two arguments.
341
+ */
312
342
int setup_revisions (int argc , const char * * argv , struct rev_info * revs ,
313
343
struct setup_revision_opt * );
344
+
314
345
void parse_revision_opt (struct rev_info * revs , struct parse_opt_ctx_t * ctx ,
315
346
const struct option * options ,
316
347
const char * const usagestr []);
@@ -319,9 +350,26 @@ void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
319
350
int handle_revision_arg (const char * arg , struct rev_info * revs ,
320
351
int flags , unsigned revarg_opt );
321
352
353
+ /**
354
+ * Reset the flags used by the revision walking api. You can use this to do
355
+ * multiple sequential revision walks.
356
+ */
322
357
void reset_revision_walk (void );
358
+
359
+ /**
360
+ * Prepares the rev_info structure for a walk. You should check if it returns
361
+ * any error (non-zero return code) and if it does not, you can start using
362
+ * get_revision() to do the iteration.
363
+ */
323
364
int prepare_revision_walk (struct rev_info * revs );
365
+
366
+ /**
367
+ * Takes a pointer to a `rev_info` structure and iterates over it, returning a
368
+ * `struct commit *` each time you call it. The end of the revision list is
369
+ * indicated by returning a NULL pointer.
370
+ */
324
371
struct commit * get_revision (struct rev_info * revs );
372
+
325
373
char * get_revision_mark (const struct rev_info * revs ,
326
374
const struct commit * commit );
327
375
void put_revision_mark (const struct rev_info * revs ,
@@ -333,8 +381,19 @@ void mark_trees_uninteresting_sparse(struct repository *r, struct oidset *trees)
333
381
334
382
void show_object_with_name (FILE * , struct object * , const char * );
335
383
384
+ /**
385
+ * This function can be used if you want to add commit objects as revision
386
+ * information. You can use the `UNINTERESTING` object flag to indicate if
387
+ * you want to include or exclude the given commit (and commits reachable
388
+ * from the given commit) from the revision list.
389
+ *
390
+ * NOTE: If you have the commits as a string list then you probably want to
391
+ * use setup_revisions(), instead of parsing each string and using this
392
+ * function.
393
+ */
336
394
void add_pending_object (struct rev_info * revs ,
337
395
struct object * obj , const char * name );
396
+
338
397
void add_pending_oid (struct rev_info * revs ,
339
398
const char * name , const struct object_id * oid ,
340
399
unsigned int flags );
0 commit comments