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