graph.hon commit general improvements (43abf13)
   1#ifndef GRAPH_H
   2#define GRAPH_H
   3#include "diff.h"
   4
   5/* A graph is a pointer to this opaque structure */
   6struct git_graph;
   7
   8/*
   9 * Called to setup global display of line_prefix diff option.
  10 *
  11 * Passed a diff_options structure which indicates the line_prefix and the
  12 * file to output the prefix to. This is sort of a hack used so that the
  13 * line_prefix will be honored by all flows which also honor "--graph"
  14 * regardless of whether a graph has actually been setup. The normal graph
  15 * flow will honor the exact diff_options passed, but a NULL graph will cause
  16 * display of a line_prefix to stdout.
  17 */
  18void graph_setup_line_prefix(struct diff_options *diffopt);
  19
  20/*
  21 * Set up a custom scheme for column colors.
  22 *
  23 * The default column color scheme inserts ANSI color escapes to colorize
  24 * the graph. The various color escapes are stored in an array of strings
  25 * where each entry corresponds to a color, except for the last entry,
  26 * which denotes the escape for resetting the color back to the default.
  27 * When generating the graph, strings from this array are inserted before
  28 * and after the various column characters.
  29 *
  30 * This function allows you to enable a custom array of color escapes.
  31 * The 'colors_max' argument is the index of the last "reset" entry.
  32 *
  33 * This functions must be called BEFORE graph_init() is called.
  34 *
  35 * NOTE: This function isn't used in Git outside graph.c but it is used
  36 * by CGit (http://git.zx2c4.com/cgit/) to use HTML for colors.
  37 */
  38void graph_set_column_colors(const char **colors, unsigned short colors_max);
  39
  40/*
  41 * Create a new struct git_graph.
  42 */
  43struct git_graph *graph_init(struct rev_info *opt);
  44
  45/*
  46 * Update a git_graph with a new commit.
  47 * This will cause the graph to begin outputting lines for the new commit
  48 * the next time graph_next_line() is called.
  49 *
  50 * If graph_update() is called before graph_is_commit_finished() returns 1,
  51 * the next call to graph_next_line() will output an ellipsis ("...")
  52 * to indicate that a portion of the graph is missing.
  53 */
  54void graph_update(struct git_graph *graph, struct commit *commit);
  55
  56/*
  57 * Determine if a graph has finished outputting lines for the current
  58 * commit.
  59 *
  60 * Returns 1 if graph_next_line() needs to be called again before
  61 * graph_update() should be called.  Returns 0 if no more lines are needed
  62 * for this commit.  If 0 is returned, graph_next_line() may still be
  63 * called without calling graph_update(), and it will merely output
  64 * appropriate "vertical padding" in the graph.
  65 */
  66int graph_is_commit_finished(struct git_graph const *graph);
  67
  68/*
  69 * Output the next line for a graph.
  70 * This formats the next graph line into the specified strbuf.  It is not
  71 * terminated with a newline.
  72 *
  73 * Returns 1 if the line includes the current commit, and 0 otherwise.
  74 * graph_next_line() will return 1 exactly once for each time
  75 * graph_update() is called.
  76 *
  77 * NOTE: This function isn't used in Git outside graph.c but it is used
  78 * by CGit (http://git.zx2c4.com/cgit/) to wrap HTML around graph lines.
  79 */
  80int graph_next_line(struct git_graph *graph, struct strbuf *sb);
  81
  82
  83/*
  84 * Return current width of the graph in on-screen characters.
  85 */
  86int graph_width(struct git_graph *graph);
  87
  88/*
  89 * graph_show_*: helper functions for printing to stdout
  90 */
  91
  92
  93/*
  94 * If the graph is non-NULL, print the history graph to stdout,
  95 * up to and including the line containing this commit.
  96 * Does not print a terminating newline on the last line.
  97 */
  98void graph_show_commit(struct git_graph *graph);
  99
 100/*
 101 * If the graph is non-NULL, print one line of the history graph to stdout.
 102 * Does not print a terminating newline on the last line.
 103 */
 104void graph_show_oneline(struct git_graph *graph);
 105
 106/*
 107 * If the graph is non-NULL, print one line of vertical graph padding to
 108 * stdout.  Does not print a terminating newline on the last line.
 109 */
 110void graph_show_padding(struct git_graph *graph);
 111
 112/*
 113 * If the graph is non-NULL, print the rest of the history graph for this
 114 * commit to stdout.  Does not print a terminating newline on the last line.
 115 */
 116int graph_show_remainder(struct git_graph *graph);
 117
 118/*
 119 * Print a commit message strbuf and the remainder of the graph to stdout.
 120 *
 121 * This is similar to graph_show_strbuf(), but it always prints the
 122 * remainder of the graph.
 123 *
 124 * If the strbuf ends with a newline, the output printed by
 125 * graph_show_commit_msg() will end with a newline.  If the strbuf is
 126 * missing a terminating newline (including if it is empty), the output
 127 * printed by graph_show_commit_msg() will also be missing a terminating
 128 * newline.
 129 *
 130 * Note that unlike some other graph display functions, you must pass the file
 131 * handle directly. It is assumed that this is the same file handle as the
 132 * file specified by the graph diff options. This is necessary so that
 133 * graph_show_commit_msg can be called even with a NULL graph.
 134 */
 135void graph_show_commit_msg(struct git_graph *graph,
 136                           FILE *file,
 137                           struct strbuf const *sb);
 138
 139#endif /* GRAPH_H */