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.

165 lines
4.2KB

  1. #ifndef STATUS_H
  2. #define STATUS_H
  3. #include "string-list.h"
  4. #include "color.h"
  5. #include "pathspec.h"
  6. #include "remote.h"
  7. struct repository;
  8. struct worktree;
  9. enum color_wt_status {
  10. WT_STATUS_HEADER = 0,
  11. WT_STATUS_UPDATED,
  12. WT_STATUS_CHANGED,
  13. WT_STATUS_UNTRACKED,
  14. WT_STATUS_NOBRANCH,
  15. WT_STATUS_UNMERGED,
  16. WT_STATUS_LOCAL_BRANCH,
  17. WT_STATUS_REMOTE_BRANCH,
  18. WT_STATUS_ONBRANCH,
  19. WT_STATUS_MAXSLOT
  20. };
  21. enum untracked_status_type {
  22. SHOW_NO_UNTRACKED_FILES,
  23. SHOW_NORMAL_UNTRACKED_FILES,
  24. SHOW_ALL_UNTRACKED_FILES
  25. };
  26. enum show_ignored_type {
  27. SHOW_NO_IGNORED,
  28. SHOW_TRADITIONAL_IGNORED,
  29. SHOW_MATCHING_IGNORED,
  30. };
  31. /* from where does this commit originate */
  32. enum commit_whence {
  33. FROM_COMMIT, /* normal */
  34. FROM_MERGE, /* commit came from merge */
  35. FROM_CHERRY_PICK /* commit came from cherry-pick */
  36. };
  37. struct wt_status_change_data {
  38. int worktree_status;
  39. int index_status;
  40. int stagemask;
  41. int mode_head, mode_index, mode_worktree;
  42. struct object_id oid_head, oid_index;
  43. int rename_status;
  44. int rename_score;
  45. char *rename_source;
  46. unsigned dirty_submodule : 2;
  47. unsigned new_submodule_commits : 1;
  48. };
  49. enum wt_status_format {
  50. STATUS_FORMAT_NONE = 0,
  51. STATUS_FORMAT_LONG,
  52. STATUS_FORMAT_SHORT,
  53. STATUS_FORMAT_PORCELAIN,
  54. STATUS_FORMAT_PORCELAIN_V2,
  55. STATUS_FORMAT_UNSPECIFIED
  56. };
  57. #define HEAD_DETACHED_AT _("HEAD detached at ")
  58. #define HEAD_DETACHED_FROM _("HEAD detached from ")
  59. struct wt_status_state {
  60. int merge_in_progress;
  61. int am_in_progress;
  62. int am_empty_patch;
  63. int rebase_in_progress;
  64. int rebase_interactive_in_progress;
  65. int cherry_pick_in_progress;
  66. int bisect_in_progress;
  67. int revert_in_progress;
  68. int detached_at;
  69. char *branch;
  70. char *onto;
  71. char *detached_from;
  72. struct object_id detached_oid;
  73. struct object_id revert_head_oid;
  74. struct object_id cherry_pick_head_oid;
  75. };
  76. struct wt_status {
  77. struct repository *repo;
  78. int is_initial;
  79. char *branch;
  80. const char *reference;
  81. struct pathspec pathspec;
  82. int verbose;
  83. int amend;
  84. enum commit_whence whence;
  85. int nowarn;
  86. int use_color;
  87. int no_gettext;
  88. int display_comment_prefix;
  89. int relative_paths;
  90. int submodule_summary;
  91. enum show_ignored_type show_ignored_mode;
  92. enum untracked_status_type show_untracked_files;
  93. const char *ignore_submodule_arg;
  94. char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
  95. unsigned colopts;
  96. int null_termination;
  97. int commit_template;
  98. int show_branch;
  99. int show_stash;
  100. int hints;
  101. enum ahead_behind_flags ahead_behind_flags;
  102. int detect_rename;
  103. int rename_score;
  104. int rename_limit;
  105. enum wt_status_format status_format;
  106. struct wt_status_state state;
  107. struct object_id oid_commit; /* when not Initial */
  108. /* These are computed during processing of the individual sections */
  109. int committable;
  110. int workdir_dirty;
  111. const char *index_file;
  112. FILE *fp;
  113. const char *prefix;
  114. struct string_list change;
  115. struct string_list untracked;
  116. struct string_list ignored;
  117. uint32_t untracked_in_ms;
  118. };
  119. size_t wt_status_locate_end(const char *s, size_t len);
  120. void wt_status_append_cut_line(struct strbuf *buf);
  121. void wt_status_add_cut_line(FILE *fp);
  122. void wt_status_prepare(struct repository *r, struct wt_status *s);
  123. void wt_status_print(struct wt_status *s);
  124. void wt_status_collect(struct wt_status *s);
  125. void wt_status_collect_free_buffers(struct wt_status *s);
  126. void wt_status_get_state(struct repository *repo,
  127. struct wt_status_state *state,
  128. int get_detached_from);
  129. int wt_status_check_rebase(const struct worktree *wt,
  130. struct wt_status_state *state);
  131. int wt_status_check_bisect(const struct worktree *wt,
  132. struct wt_status_state *state);
  133. __attribute__((format (printf, 3, 4)))
  134. void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...);
  135. __attribute__((format (printf, 3, 4)))
  136. void status_printf(struct wt_status *s, const char *color, const char *fmt, ...);
  137. /* The following functions expect that the caller took care of reading the index. */
  138. int has_unstaged_changes(struct repository *repo,
  139. int ignore_submodules);
  140. int has_uncommitted_changes(struct repository *repo,
  141. int ignore_submodules);
  142. int require_clean_work_tree(struct repository *repo,
  143. const char *action,
  144. const char *hint,
  145. int ignore_submodules,
  146. int gently);
  147. #endif /* STATUS_H */