Jeff King | c91f0d9 | 2006-09-08 04:05:34 -0400 | [diff] [blame] | 1 | #ifndef STATUS_H |
| 2 | #define STATUS_H |
| 3 | |
Kristian Høgsberg | f26a001 | 2007-09-17 20:06:42 -0400 | [diff] [blame] | 4 | #include <stdio.h> |
Junio C Hamano | 50b7e70 | 2009-08-04 23:49:33 -0700 | [diff] [blame] | 5 | #include "string-list.h" |
Junio C Hamano | 23900a9 | 2009-08-09 23:08:40 -0700 | [diff] [blame] | 6 | #include "color.h" |
SZEDER Gábor | 7aa9b9b | 2015-08-20 16:06:27 +0200 | [diff] [blame] | 7 | #include "pathspec.h" |
Jeff Hostetler | fd9b544 | 2018-01-09 18:50:16 +0000 | [diff] [blame] | 8 | #include "remote.h" |
Kristian Høgsberg | f26a001 | 2007-09-17 20:06:42 -0400 | [diff] [blame] | 9 | |
Nguyễn Thái Ngọc Duy | 5b02ca3 | 2018-11-10 06:48:49 +0100 | [diff] [blame] | 10 | struct repository; |
Nguyễn Thái Ngọc Duy | 81eff27 | 2016-04-22 20:01:31 +0700 | [diff] [blame] | 11 | struct worktree; |
| 12 | |
Jeff King | c91f0d9 | 2006-09-08 04:05:34 -0400 | [diff] [blame] | 13 | enum color_wt_status { |
Junio C Hamano | 23900a9 | 2009-08-09 23:08:40 -0700 | [diff] [blame] | 14 | WT_STATUS_HEADER = 0, |
Jeff King | c91f0d9 | 2006-09-08 04:05:34 -0400 | [diff] [blame] | 15 | WT_STATUS_UPDATED, |
| 16 | WT_STATUS_CHANGED, |
| 17 | WT_STATUS_UNTRACKED, |
Chris Parsons | 950ce2e | 2008-05-22 08:50:02 -0400 | [diff] [blame] | 18 | WT_STATUS_NOBRANCH, |
Junio C Hamano | 4d4d572 | 2009-08-05 00:04:51 -0700 | [diff] [blame] | 19 | WT_STATUS_UNMERGED, |
Daniel Knittl-Frank | 05a59a0 | 2010-05-25 15:45:51 +0200 | [diff] [blame] | 20 | WT_STATUS_LOCAL_BRANCH, |
Aleksi Aalto | 1d28232 | 2010-11-18 01:40:05 +0200 | [diff] [blame] | 21 | WT_STATUS_REMOTE_BRANCH, |
| 22 | WT_STATUS_ONBRANCH, |
| 23 | WT_STATUS_MAXSLOT |
Jeff King | c91f0d9 | 2006-09-08 04:05:34 -0400 | [diff] [blame] | 24 | }; |
| 25 | |
Marius Storm-Olsen | 4bfee30 | 2008-06-05 10:31:19 +0200 | [diff] [blame] | 26 | enum untracked_status_type { |
Marius Storm-Olsen | 6c2ce04 | 2008-06-05 14:22:56 +0200 | [diff] [blame] | 27 | SHOW_NO_UNTRACKED_FILES, |
| 28 | SHOW_NORMAL_UNTRACKED_FILES, |
Marius Storm-Olsen | 4bfee30 | 2008-06-05 10:31:19 +0200 | [diff] [blame] | 29 | SHOW_ALL_UNTRACKED_FILES |
| 30 | }; |
Marius Storm-Olsen | 4bfee30 | 2008-06-05 10:31:19 +0200 | [diff] [blame] | 31 | |
Jameson Miller | eec0f7f | 2017-10-30 13:21:37 -0400 | [diff] [blame] | 32 | enum show_ignored_type { |
| 33 | SHOW_NO_IGNORED, |
| 34 | SHOW_TRADITIONAL_IGNORED, |
| 35 | SHOW_MATCHING_IGNORED, |
| 36 | }; |
| 37 | |
Jay Soffian | 37f7a85 | 2011-02-19 23:12:29 -0500 | [diff] [blame] | 38 | /* from where does this commit originate */ |
| 39 | enum commit_whence { |
| 40 | FROM_COMMIT, /* normal */ |
| 41 | FROM_MERGE, /* commit came from merge */ |
| 42 | FROM_CHERRY_PICK /* commit came from cherry-pick */ |
| 43 | }; |
| 44 | |
Junio C Hamano | 50b7e70 | 2009-08-04 23:49:33 -0700 | [diff] [blame] | 45 | struct wt_status_change_data { |
| 46 | int worktree_status; |
| 47 | int index_status; |
| 48 | int stagemask; |
Jeff Hostetler | 1ecdecc | 2016-08-11 10:45:57 -0400 | [diff] [blame] | 49 | int mode_head, mode_index, mode_worktree; |
| 50 | struct object_id oid_head, oid_index; |
Nguyễn Thái Ngọc Duy | 5134ccd | 2017-12-27 17:18:38 +0700 | [diff] [blame] | 51 | int rename_status; |
| 52 | int rename_score; |
| 53 | char *rename_source; |
Jens Lehmann | 9297f77e6 | 2010-03-08 13:53:19 +0100 | [diff] [blame] | 54 | unsigned dirty_submodule : 2; |
| 55 | unsigned new_submodule_commits : 1; |
Junio C Hamano | 50b7e70 | 2009-08-04 23:49:33 -0700 | [diff] [blame] | 56 | }; |
| 57 | |
Jeff Hostetler | be7e795 | 2016-08-05 18:00:27 -0400 | [diff] [blame] | 58 | enum wt_status_format { |
| 59 | STATUS_FORMAT_NONE = 0, |
| 60 | STATUS_FORMAT_LONG, |
| 61 | STATUS_FORMAT_SHORT, |
| 62 | STATUS_FORMAT_PORCELAIN, |
Jeff Hostetler | 1ecdecc | 2016-08-11 10:45:57 -0400 | [diff] [blame] | 63 | STATUS_FORMAT_PORCELAIN_V2, |
Jeff Hostetler | be7e795 | 2016-08-05 18:00:27 -0400 | [diff] [blame] | 64 | |
| 65 | STATUS_FORMAT_UNSPECIFIED |
| 66 | }; |
| 67 | |
Stephen P. Smith | 73ba5d7 | 2018-09-30 07:12:45 -0700 | [diff] [blame] | 68 | struct wt_status_state { |
| 69 | int merge_in_progress; |
| 70 | int am_in_progress; |
| 71 | int am_empty_patch; |
| 72 | int rebase_in_progress; |
| 73 | int rebase_interactive_in_progress; |
| 74 | int cherry_pick_in_progress; |
| 75 | int bisect_in_progress; |
| 76 | int revert_in_progress; |
| 77 | int detached_at; |
| 78 | char *branch; |
| 79 | char *onto; |
| 80 | char *detached_from; |
| 81 | struct object_id detached_oid; |
| 82 | struct object_id revert_head_oid; |
| 83 | struct object_id cherry_pick_head_oid; |
| 84 | }; |
| 85 | |
Jeff King | c91f0d9 | 2006-09-08 04:05:34 -0400 | [diff] [blame] | 86 | struct wt_status { |
Nguyễn Thái Ngọc Duy | 5b02ca3 | 2018-11-10 06:48:49 +0100 | [diff] [blame] | 87 | struct repository *repo; |
Jeff King | c91f0d9 | 2006-09-08 04:05:34 -0400 | [diff] [blame] | 88 | int is_initial; |
| 89 | char *branch; |
| 90 | const char *reference; |
Nguyễn Thái Ngọc Duy | 15b55ae | 2013-07-14 15:35:39 +0700 | [diff] [blame] | 91 | struct pathspec pathspec; |
Jeff King | c91f0d9 | 2006-09-08 04:05:34 -0400 | [diff] [blame] | 92 | int verbose; |
| 93 | int amend; |
Jay Soffian | 37f7a85 | 2011-02-19 23:12:29 -0500 | [diff] [blame] | 94 | enum commit_whence whence; |
Junio C Hamano | 37d07f8 | 2007-12-12 19:09:16 -0800 | [diff] [blame] | 95 | int nowarn; |
Junio C Hamano | d249b09 | 2009-08-09 21:59:30 -0700 | [diff] [blame] | 96 | int use_color; |
Matthieu Moy | 7a76c28 | 2014-03-20 13:12:41 +0100 | [diff] [blame] | 97 | int no_gettext; |
Matthieu Moy | 2556b99 | 2013-09-06 19:43:07 +0200 | [diff] [blame] | 98 | int display_comment_prefix; |
Junio C Hamano | d249b09 | 2009-08-09 21:59:30 -0700 | [diff] [blame] | 99 | int relative_paths; |
| 100 | int submodule_summary; |
Jameson Miller | eec0f7f | 2017-10-30 13:21:37 -0400 | [diff] [blame] | 101 | enum show_ignored_type show_ignored_mode; |
Junio C Hamano | d249b09 | 2009-08-09 21:59:30 -0700 | [diff] [blame] | 102 | enum untracked_status_type show_untracked_files; |
Jens Lehmann | 46a958b | 2010-06-25 16:56:47 +0200 | [diff] [blame] | 103 | const char *ignore_submodule_arg; |
Aleksi Aalto | 1d28232 | 2010-11-18 01:40:05 +0200 | [diff] [blame] | 104 | char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN]; |
Jeff King | 4d2292e | 2012-05-07 15:35:03 -0400 | [diff] [blame] | 105 | unsigned colopts; |
Jeff King | 3207a3a | 2012-05-07 15:44:44 -0400 | [diff] [blame] | 106 | int null_termination; |
Kaartic Sivaraam | 4ddb135 | 2017-06-21 23:46:14 +0530 | [diff] [blame] | 107 | int commit_template; |
Jeff King | d4a6bf1 | 2012-05-07 17:09:04 -0400 | [diff] [blame] | 108 | int show_branch; |
Liam Beguin | c1b5d01 | 2017-06-17 18:30:51 -0400 | [diff] [blame] | 109 | int show_stash; |
Matthieu Moy | 6a964f5 | 2013-09-12 12:50:05 +0200 | [diff] [blame] | 110 | int hints; |
Jeff Hostetler | fd9b544 | 2018-01-09 18:50:16 +0000 | [diff] [blame] | 111 | enum ahead_behind_flags ahead_behind_flags; |
Ben Peart | e8b2dc2 | 2018-05-11 15:38:58 +0000 | [diff] [blame] | 112 | int detect_rename; |
| 113 | int rename_score; |
| 114 | int rename_limit; |
Jeff Hostetler | be7e795 | 2016-08-05 18:00:27 -0400 | [diff] [blame] | 115 | enum wt_status_format status_format; |
Stephen P. Smith | 73ba5d7 | 2018-09-30 07:12:45 -0700 | [diff] [blame] | 116 | struct wt_status_state state; |
brian m. carlson | cd02599 | 2017-03-26 16:01:25 +0000 | [diff] [blame] | 117 | unsigned char sha1_commit[GIT_MAX_RAWSZ]; /* when not Initial */ |
Jeff Hostetler | be7e795 | 2016-08-05 18:00:27 -0400 | [diff] [blame] | 118 | |
Jürgen Rühle | 2a3a3c2 | 2007-01-10 23:25:03 +0100 | [diff] [blame] | 119 | /* These are computed during processing of the individual sections */ |
Stephen P. Smith | 6fa9019 | 2018-09-05 17:53:27 -0700 | [diff] [blame] | 120 | int committable; |
Jürgen Rühle | 2a3a3c2 | 2007-01-10 23:25:03 +0100 | [diff] [blame] | 121 | int workdir_dirty; |
Kristian Høgsberg | 0f729f2 | 2007-09-17 20:06:43 -0400 | [diff] [blame] | 122 | const char *index_file; |
Kristian Høgsberg | f26a001 | 2007-09-17 20:06:42 -0400 | [diff] [blame] | 123 | FILE *fp; |
Johannes Schindelin | 367c988 | 2007-11-11 17:35:41 +0000 | [diff] [blame] | 124 | const char *prefix; |
Junio C Hamano | 50b7e70 | 2009-08-04 23:49:33 -0700 | [diff] [blame] | 125 | struct string_list change; |
Junio C Hamano | 7637868 | 2009-08-10 00:36:33 -0700 | [diff] [blame] | 126 | struct string_list untracked; |
Junio C Hamano | 6cb3f6b | 2010-04-10 00:11:53 -0700 | [diff] [blame] | 127 | struct string_list ignored; |
Nguyễn Thái Ngọc Duy | 6a38ef2 | 2013-03-13 19:59:16 +0700 | [diff] [blame] | 128 | uint32_t untracked_in_ms; |
Jeff King | c91f0d9 | 2006-09-08 04:05:34 -0400 | [diff] [blame] | 129 | }; |
| 130 | |
Brian Malehorn | d76650b | 2017-05-15 23:06:49 -0700 | [diff] [blame] | 131 | size_t wt_status_locate_end(const char *s, size_t len); |
Denton Liu | d540b70 | 2019-04-17 11:23:27 +0100 | [diff] [blame] | 132 | void wt_status_append_cut_line(struct strbuf *buf); |
Nguyễn Thái Ngọc Duy | fcef931 | 2014-02-17 19:15:31 +0700 | [diff] [blame] | 133 | void wt_status_add_cut_line(FILE *fp); |
Nguyễn Thái Ngọc Duy | 5b02ca3 | 2018-11-10 06:48:49 +0100 | [diff] [blame] | 134 | void wt_status_prepare(struct repository *r, struct wt_status *s); |
Jeff Hostetler | be7e795 | 2016-08-05 18:00:27 -0400 | [diff] [blame] | 135 | void wt_status_print(struct wt_status *s); |
Junio C Hamano | 7637868 | 2009-08-10 00:36:33 -0700 | [diff] [blame] | 136 | void wt_status_collect(struct wt_status *s); |
Stephen P. Smith | 73ba5d7 | 2018-09-30 07:12:45 -0700 | [diff] [blame] | 137 | void wt_status_collect_free_buffers(struct wt_status *s); |
Nguyễn Thái Ngọc Duy | 7884545 | 2018-11-10 06:48:50 +0100 | [diff] [blame] | 138 | void wt_status_get_state(struct repository *repo, |
| 139 | struct wt_status_state *state, |
| 140 | int get_detached_from); |
Nguyễn Thái Ngọc Duy | 81eff27 | 2016-04-22 20:01:31 +0700 | [diff] [blame] | 141 | int wt_status_check_rebase(const struct worktree *wt, |
| 142 | struct wt_status_state *state); |
Nguyễn Thái Ngọc Duy | f5d067a | 2016-04-22 20:01:34 +0700 | [diff] [blame] | 143 | int wt_status_check_bisect(const struct worktree *wt, |
| 144 | struct wt_status_state *state); |
Jeff King | c91f0d9 | 2006-09-08 04:05:34 -0400 | [diff] [blame] | 145 | |
Jeff King | 8dd0ee8 | 2013-07-09 20:23:28 -0400 | [diff] [blame] | 146 | __attribute__((format (printf, 3, 4))) |
| 147 | void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...); |
| 148 | __attribute__((format (printf, 3, 4))) |
| 149 | void status_printf(struct wt_status *s, const char *color, const char *fmt, ...); |
Jonathan Nieder | becbdae | 2011-02-25 23:09:41 -0600 | [diff] [blame] | 150 | |
Johannes Schindelin | 41a5dd6 | 2016-10-07 18:08:56 +0200 | [diff] [blame] | 151 | /* The following functions expect that the caller took care of reading the index. */ |
Nguyễn Thái Ngọc Duy | 5b02ca3 | 2018-11-10 06:48:49 +0100 | [diff] [blame] | 152 | int has_unstaged_changes(struct repository *repo, |
| 153 | int ignore_submodules); |
| 154 | int has_uncommitted_changes(struct repository *repo, |
| 155 | int ignore_submodules); |
| 156 | int require_clean_work_tree(struct repository *repo, |
| 157 | const char *action, |
| 158 | const char *hint, |
| 159 | int ignore_submodules, |
| 160 | int gently); |
Johannes Schindelin | fd84986 | 2016-10-07 18:08:38 +0200 | [diff] [blame] | 161 | |
Jeff King | c91f0d9 | 2006-09-08 04:05:34 -0400 | [diff] [blame] | 162 | #endif /* STATUS_H */ |