THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
4.9KB

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