graph.hon commit Merge branch 'jk/stash-options' (f693bb0)
   1#ifndef GRAPH_H
   2#define GRAPH_H
   3
   4/* A graph is a pointer to this opaque structure */
   5struct git_graph;
   6
   7/*
   8 * Set up a custom scheme for column colors.
   9 *
  10 * The default column color scheme inserts ANSI color escapes to colorize
  11 * the graph. The various color escapes are stored in an array of strings
  12 * where each entry corresponds to a color, except for the last entry,
  13 * which denotes the escape for resetting the color back to the default.
  14 * When generating the graph, strings from this array are inserted before
  15 * and after the various column characters.
  16 *
  17 * This function allows you to enable a custom array of color escapes.
  18 * The 'colors_max' argument is the index of the last "reset" entry.
  19 *
  20 * This functions must be called BEFORE graph_init() is called.
  21 *
  22 * NOTE: This function isn't used in Git outside graph.c but it is used
  23 * by CGit (http://git.zx2c4.com/cgit/) to use HTML for colors.
  24 */
  25void graph_set_column_colors(const char **colors, unsigned short colors_max);
  26
  27/*
  28 * Create a new struct git_graph.
  29 */
  30struct git_graph *graph_init(struct rev_info *opt);
  31
  32/*
  33 * Update a git_graph with a new commit.
  34 * This will cause the graph to begin outputting lines for the new commit
  35 * the next time graph_next_line() is called.
  36 *
  37 * If graph_update() is called before graph_is_commit_finished() returns 1,
  38 * the next call to graph_next_line() will output an ellipsis ("...")
  39 * to indicate that a portion of the graph is missing.
  40 */
  41void graph_update(struct git_graph *graph, struct commit *commit);
  42
  43/*
  44 * Determine if a graph has finished outputting lines for the current
  45 * commit.
  46 *
  47 * Returns 1 if graph_next_line() needs to be called again before
  48 * graph_update() should be called.  Returns 0 if no more lines are needed
  49 * for this commit.  If 0 is returned, graph_next_line() may still be
  50 * called without calling graph_update(), and it will merely output
  51 * appropriate "vertical padding" in the graph.
  52 */
  53int graph_is_commit_finished(struct git_graph const *graph);
  54
  55/*
  56 * Output the next line for a graph.
  57 * This formats the next graph line into the specified strbuf.  It is not
  58 * terminated with a newline.
  59 *
  60 * Returns 1 if the line includes the current commit, and 0 otherwise.
  61 * graph_next_line() will return 1 exactly once for each time
  62 * graph_update() is called.
  63 *
  64 * NOTE: This function isn't used in Git outside graph.c but it is used
  65 * by CGit (http://git.zx2c4.com/cgit/) to wrap HTML around graph lines.
  66 */
  67int graph_next_line(struct git_graph *graph, struct strbuf *sb);
  68
  69
  70/*
  71 * graph_show_*: helper functions for printing to stdout
  72 */
  73
  74
  75/*
  76 * If the graph is non-NULL, print the history graph to stdout,
  77 * up to and including the line containing this commit.
  78 * Does not print a terminating newline on the last line.
  79 */
  80void graph_show_commit(struct git_graph *graph);
  81
  82/*
  83 * If the graph is non-NULL, print one line of the history graph to stdout.
  84 * Does not print a terminating newline on the last line.
  85 */
  86void graph_show_oneline(struct git_graph *graph);
  87
  88/*
  89 * If the graph is non-NULL, print one line of vertical graph padding to
  90 * stdout.  Does not print a terminating newline on the last line.
  91 */
  92void graph_show_padding(struct git_graph *graph);
  93
  94/*
  95 * If the graph is non-NULL, print the rest of the history graph for this
  96 * commit to stdout.  Does not print a terminating newline on the last line.
  97 */
  98int graph_show_remainder(struct git_graph *graph);
  99
 100/*
 101 * Print a commit message strbuf and the remainder of the graph to stdout.
 102 *
 103 * This is similar to graph_show_strbuf(), but it always prints the
 104 * remainder of the graph.
 105 *
 106 * If the strbuf ends with a newline, the output printed by
 107 * graph_show_commit_msg() will end with a newline.  If the strbuf is
 108 * missing a terminating newline (including if it is empty), the output
 109 * printed by graph_show_commit_msg() will also be missing a terminating
 110 * newline.
 111 */
 112void graph_show_commit_msg(struct git_graph *graph, struct strbuf const *sb);
 113
 114#endif /* GRAPH_H */