blob: 2ca93f6957f69cd5652ddc764f5afe81b598a2a9 [file] [log] [blame]
Jeff Kingc91f0d92006-09-08 04:05:34 -04001#ifndef STATUS_H
2#define STATUS_H
3
Kristian Høgsbergf26a0012007-09-17 20:06:42 -04004#include <stdio.h>
Junio C Hamano50b7e702009-08-04 23:49:33 -07005#include "string-list.h"
Junio C Hamano23900a92009-08-09 23:08:40 -07006#include "color.h"
SZEDER Gábor7aa9b9b2015-08-20 16:06:27 +02007#include "pathspec.h"
Kristian Høgsbergf26a0012007-09-17 20:06:42 -04008
Nguyễn Thái Ngọc Duy81eff272016-04-22 20:01:31 +07009struct worktree;
10
Jeff Kingc91f0d92006-09-08 04:05:34 -040011enum color_wt_status {
Junio C Hamano23900a92009-08-09 23:08:40 -070012 WT_STATUS_HEADER = 0,
Jeff Kingc91f0d92006-09-08 04:05:34 -040013 WT_STATUS_UPDATED,
14 WT_STATUS_CHANGED,
15 WT_STATUS_UNTRACKED,
Chris Parsons950ce2e2008-05-22 08:50:02 -040016 WT_STATUS_NOBRANCH,
Junio C Hamano4d4d5722009-08-05 00:04:51 -070017 WT_STATUS_UNMERGED,
Daniel Knittl-Frank05a59a02010-05-25 15:45:51 +020018 WT_STATUS_LOCAL_BRANCH,
Aleksi Aalto1d282322010-11-18 01:40:05 +020019 WT_STATUS_REMOTE_BRANCH,
20 WT_STATUS_ONBRANCH,
21 WT_STATUS_MAXSLOT
Jeff Kingc91f0d92006-09-08 04:05:34 -040022};
23
Marius Storm-Olsen4bfee302008-06-05 10:31:19 +020024enum untracked_status_type {
Marius Storm-Olsen6c2ce042008-06-05 14:22:56 +020025 SHOW_NO_UNTRACKED_FILES,
26 SHOW_NORMAL_UNTRACKED_FILES,
Marius Storm-Olsen4bfee302008-06-05 10:31:19 +020027 SHOW_ALL_UNTRACKED_FILES
28};
Marius Storm-Olsen4bfee302008-06-05 10:31:19 +020029
Jay Soffian37f7a852011-02-19 23:12:29 -050030/* from where does this commit originate */
31enum 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 Hamano50b7e702009-08-04 23:49:33 -070037struct wt_status_change_data {
38 int worktree_status;
39 int index_status;
40 int stagemask;
41 char *head_path;
Jens Lehmann9297f77e62010-03-08 13:53:19 +010042 unsigned dirty_submodule : 2;
43 unsigned new_submodule_commits : 1;
Junio C Hamano50b7e702009-08-04 23:49:33 -070044};
45
Jeff Kingc91f0d92006-09-08 04:05:34 -040046struct wt_status {
47 int is_initial;
48 char *branch;
49 const char *reference;
Nguyễn Thái Ngọc Duy15b55ae2013-07-14 15:35:39 +070050 struct pathspec pathspec;
Jeff Kingc91f0d92006-09-08 04:05:34 -040051 int verbose;
52 int amend;
Jay Soffian37f7a852011-02-19 23:12:29 -050053 enum commit_whence whence;
Junio C Hamano37d07f82007-12-12 19:09:16 -080054 int nowarn;
Junio C Hamanod249b092009-08-09 21:59:30 -070055 int use_color;
Matthieu Moy7a76c282014-03-20 13:12:41 +010056 int no_gettext;
Matthieu Moy2556b992013-09-06 19:43:07 +020057 int display_comment_prefix;
Junio C Hamanod249b092009-08-09 21:59:30 -070058 int relative_paths;
59 int submodule_summary;
Junio C Hamano6cb3f6b2010-04-10 00:11:53 -070060 int show_ignored_files;
Junio C Hamanod249b092009-08-09 21:59:30 -070061 enum untracked_status_type show_untracked_files;
Jens Lehmann46a958b2010-06-25 16:56:47 +020062 const char *ignore_submodule_arg;
Aleksi Aalto1d282322010-11-18 01:40:05 +020063 char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
Jeff King4d2292e2012-05-07 15:35:03 -040064 unsigned colopts;
Jeff King3207a3a2012-05-07 15:44:44 -040065 int null_termination;
Jeff Kingd4a6bf12012-05-07 17:09:04 -040066 int show_branch;
Matthieu Moy6a964f52013-09-12 12:50:05 +020067 int hints;
Junio C Hamanod249b092009-08-09 21:59:30 -070068
Jürgen Rühle2a3a3c22007-01-10 23:25:03 +010069 /* These are computed during processing of the individual sections */
70 int commitable;
71 int workdir_dirty;
Kristian Høgsberg0f729f22007-09-17 20:06:43 -040072 const char *index_file;
Kristian Høgsbergf26a0012007-09-17 20:06:42 -040073 FILE *fp;
Johannes Schindelin367c9882007-11-11 17:35:41 +000074 const char *prefix;
Junio C Hamano50b7e702009-08-04 23:49:33 -070075 struct string_list change;
Junio C Hamano76378682009-08-10 00:36:33 -070076 struct string_list untracked;
Junio C Hamano6cb3f6b2010-04-10 00:11:53 -070077 struct string_list ignored;
Nguyễn Thái Ngọc Duy6a38ef22013-03-13 19:59:16 +070078 uint32_t untracked_in_ms;
Jeff Kingc91f0d92006-09-08 04:05:34 -040079};
80
Lucien Kong83c750a2012-06-05 22:21:24 +020081struct wt_status_state {
82 int merge_in_progress;
83 int am_in_progress;
84 int am_empty_patch;
85 int rebase_in_progress;
86 int rebase_interactive_in_progress;
87 int cherry_pick_in_progress;
88 int bisect_in_progress;
Matthieu Moydb4ef442013-04-02 16:20:21 +020089 int revert_in_progress;
Michael J Gruber970399e2015-03-06 16:04:06 +010090 int detached_at;
Nguyễn Thái Ngọc Duy8b87cfd2013-03-16 09:12:36 +070091 char *branch;
92 char *onto;
Nguyễn Thái Ngọc Duyb397ea42013-03-13 18:42:52 +070093 char *detached_from;
94 unsigned char detached_sha1[20];
Matthieu Moy87e139c2013-04-02 16:20:22 +020095 unsigned char revert_head_sha1[20];
Ralf Thielowbffd8092013-10-11 17:58:37 +020096 unsigned char cherry_pick_head_sha1[20];
Lucien Kong83c750a2012-06-05 22:21:24 +020097};
98
Jens Lehmann1a72cfd2013-12-05 20:44:14 +010099void wt_status_truncate_message_at_cut_line(struct strbuf *);
Nguyễn Thái Ngọc Duyfcef9312014-02-17 19:15:31 +0700100void wt_status_add_cut_line(FILE *fp);
Jeff Kingc91f0d92006-09-08 04:05:34 -0400101void wt_status_prepare(struct wt_status *s);
102void wt_status_print(struct wt_status *s);
Junio C Hamano76378682009-08-10 00:36:33 -0700103void wt_status_collect(struct wt_status *s);
Nguyễn Thái Ngọc Duyb397ea42013-03-13 18:42:52 +0700104void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
Nguyễn Thái Ngọc Duy81eff272016-04-22 20:01:31 +0700105int wt_status_check_rebase(const struct worktree *wt,
106 struct wt_status_state *state);
Nguyễn Thái Ngọc Duyf5d067a2016-04-22 20:01:34 +0700107int wt_status_check_bisect(const struct worktree *wt,
108 struct wt_status_state *state);
Jeff Kingc91f0d92006-09-08 04:05:34 -0400109
Jeff Kingd4a6bf12012-05-07 17:09:04 -0400110void wt_shortstatus_print(struct wt_status *s);
Jeff King3207a3a2012-05-07 15:44:44 -0400111void wt_porcelain_print(struct wt_status *s);
Michael J Gruber84dbe7b2009-12-05 16:04:37 +0100112
Jeff King8dd0ee82013-07-09 20:23:28 -0400113__attribute__((format (printf, 3, 4)))
114void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...);
115__attribute__((format (printf, 3, 4)))
116void status_printf(struct wt_status *s, const char *color, const char *fmt, ...);
Jonathan Niederbecbdae2011-02-25 23:09:41 -0600117
Jeff Kingc91f0d92006-09-08 04:05:34 -0400118#endif /* STATUS_H */