graph.hon commit update-index: refuse to add working tree items beyond symlinks (806d13b)
   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 * Create a new struct git_graph.
   9 * The graph should be freed with graph_release() when no longer needed.
  10 */
  11struct git_graph *graph_init(struct rev_info *opt);
  12
  13/*
  14 * Destroy a struct git_graph and free associated memory.
  15 */
  16void graph_release(struct git_graph *graph);
  17
  18/*
  19 * Update a git_graph with a new commit.
  20 * This will cause the graph to begin outputting lines for the new commit
  21 * the next time graph_next_line() is called.
  22 *
  23 * If graph_update() is called before graph_is_commit_finished() returns 1,
  24 * the next call to graph_next_line() will output an ellipsis ("...")
  25 * to indicate that a portion of the graph is missing.
  26 */
  27void graph_update(struct git_graph *graph, struct commit *commit);
  28
  29/*
  30 * Output the next line for a graph.
  31 * This formats the next graph line into the specified strbuf.  It is not
  32 * terminated with a newline.
  33 *
  34 * Returns 1 if the line includes the current commit, and 0 otherwise.
  35 * graph_next_line() will return 1 exactly once for each time
  36 * graph_update() is called.
  37 */
  38int graph_next_line(struct git_graph *graph, struct strbuf *sb);
  39
  40/*
  41 * Output a padding line in the graph.
  42 * This is similar to graph_next_line().  However, it is guaranteed to
  43 * never print the current commit line.  Instead, if the commit line is
  44 * next, it will simply output a line of vertical padding, extending the
  45 * branch lines downwards, but leaving them otherwise unchanged.
  46 */
  47void graph_padding_line(struct git_graph *graph, struct strbuf *sb);
  48
  49/*
  50 * Determine if a graph has finished outputting lines for the current
  51 * commit.
  52 *
  53 * Returns 1 if graph_next_line() needs to be called again before
  54 * graph_update() should be called.  Returns 0 if no more lines are needed
  55 * for this commit.  If 0 is returned, graph_next_line() may still be
  56 * called without calling graph_update(), and it will merely output
  57 * appropriate "vertical padding" in the graph.
  58 */
  59int graph_is_commit_finished(struct git_graph const *graph);
  60
  61
  62/*
  63 * graph_show_*: helper functions for printing to stdout
  64 */
  65
  66
  67/*
  68 * If the graph is non-NULL, print the history graph to stdout,
  69 * up to and including the line containing this commit.
  70 * Does not print a terminating newline on the last line.
  71 */
  72void graph_show_commit(struct git_graph *graph);
  73
  74/*
  75 * If the graph is non-NULL, print one line of the history graph to stdout.
  76 * Does not print a terminating newline on the last line.
  77 */
  78void graph_show_oneline(struct git_graph *graph);
  79
  80/*
  81 * If the graph is non-NULL, print one line of vertical graph padding to
  82 * stdout.  Does not print a terminating newline on the last line.
  83 */
  84void graph_show_padding(struct git_graph *graph);
  85
  86/*
  87 * If the graph is non-NULL, print the rest of the history graph for this
  88 * commit to stdout.  Does not print a terminating newline on the last line.
  89 */
  90int graph_show_remainder(struct git_graph *graph);
  91
  92/*
  93 * Print a strbuf to stdout.  If the graph is non-NULL, all lines but the
  94 * first will be prefixed with the graph output.
  95 *
  96 * If the strbuf ends with a newline, the output will end after this
  97 * newline.  A new graph line will not be printed after the final newline.
  98 * If the strbuf is empty, no output will be printed.
  99 *
 100 * Since the first line will not include the graph ouput, the caller is
 101 * responsible for printing this line's graph (perhaps via
 102 * graph_show_commit() or graph_show_oneline()) before calling
 103 * graph_show_strbuf().
 104 */
 105void graph_show_strbuf(struct git_graph *graph, struct strbuf const *sb);
 106
 107/*
 108 * Print a commit message strbuf and the remainder of the graph to stdout.
 109 *
 110 * This is similar to graph_show_strbuf(), but it always prints the
 111 * remainder of the graph.
 112 *
 113 * If the strbuf ends with a newline, the output printed by
 114 * graph_show_commit_msg() will end with a newline.  If the strbuf is
 115 * missing a terminating newline (including if it is empty), the output
 116 * printed by graph_show_commit_msg() will also be missing a terminating
 117 * newline.
 118 */
 119void graph_show_commit_msg(struct git_graph *graph, struct strbuf const *sb);
 120
 121#endif /* GRAPH_H */