blob: 6c29e6f5e57f84eb7acdc3cf1ee621cc717fd5a9 [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"
Kristian Høgsbergf26a0012007-09-17 20:06:42 -04007
Jeff Kingc91f0d92006-09-08 04:05:34 -04008enum color_wt_status {
Junio C Hamano23900a92009-08-09 23:08:40 -07009 WT_STATUS_HEADER = 0,
Jeff Kingc91f0d92006-09-08 04:05:34 -040010 WT_STATUS_UPDATED,
11 WT_STATUS_CHANGED,
12 WT_STATUS_UNTRACKED,
Chris Parsons950ce2e2008-05-22 08:50:02 -040013 WT_STATUS_NOBRANCH,
Junio C Hamano4d4d5722009-08-05 00:04:51 -070014 WT_STATUS_UNMERGED,
Daniel Knittl-Frank05a59a02010-05-25 15:45:51 +020015 WT_STATUS_LOCAL_BRANCH,
Aleksi Aalto1d282322010-11-18 01:40:05 +020016 WT_STATUS_REMOTE_BRANCH,
17 WT_STATUS_ONBRANCH,
18 WT_STATUS_MAXSLOT
Jeff Kingc91f0d92006-09-08 04:05:34 -040019};
20
Marius Storm-Olsen4bfee302008-06-05 10:31:19 +020021enum untracked_status_type {
Marius Storm-Olsen6c2ce042008-06-05 14:22:56 +020022 SHOW_NO_UNTRACKED_FILES,
23 SHOW_NORMAL_UNTRACKED_FILES,
Marius Storm-Olsen4bfee302008-06-05 10:31:19 +020024 SHOW_ALL_UNTRACKED_FILES
25};
Marius Storm-Olsen4bfee302008-06-05 10:31:19 +020026
Jay Soffian37f7a852011-02-19 23:12:29 -050027/* from where does this commit originate */
28enum commit_whence {
29 FROM_COMMIT, /* normal */
30 FROM_MERGE, /* commit came from merge */
31 FROM_CHERRY_PICK /* commit came from cherry-pick */
32};
33
Junio C Hamano50b7e702009-08-04 23:49:33 -070034struct wt_status_change_data {
35 int worktree_status;
36 int index_status;
37 int stagemask;
38 char *head_path;
Jens Lehmann9297f77e62010-03-08 13:53:19 +010039 unsigned dirty_submodule : 2;
40 unsigned new_submodule_commits : 1;
Junio C Hamano50b7e702009-08-04 23:49:33 -070041};
42
Jeff Kingc91f0d92006-09-08 04:05:34 -040043struct wt_status {
44 int is_initial;
45 char *branch;
46 const char *reference;
Nguyễn Thái Ngọc Duy15b55ae2013-07-14 15:35:39 +070047 struct pathspec pathspec;
Jeff Kingc91f0d92006-09-08 04:05:34 -040048 int verbose;
49 int amend;
Jay Soffian37f7a852011-02-19 23:12:29 -050050 enum commit_whence whence;
Junio C Hamano37d07f82007-12-12 19:09:16 -080051 int nowarn;
Junio C Hamanod249b092009-08-09 21:59:30 -070052 int use_color;
Matthieu Moy2556b992013-09-06 19:43:07 +020053 int display_comment_prefix;
Junio C Hamanod249b092009-08-09 21:59:30 -070054 int relative_paths;
55 int submodule_summary;
Junio C Hamano6cb3f6b2010-04-10 00:11:53 -070056 int show_ignored_files;
Junio C Hamanod249b092009-08-09 21:59:30 -070057 enum untracked_status_type show_untracked_files;
Jens Lehmann46a958b2010-06-25 16:56:47 +020058 const char *ignore_submodule_arg;
Aleksi Aalto1d282322010-11-18 01:40:05 +020059 char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
Jeff King4d2292e2012-05-07 15:35:03 -040060 unsigned colopts;
Jeff King3207a3a2012-05-07 15:44:44 -040061 int null_termination;
Jeff Kingd4a6bf12012-05-07 17:09:04 -040062 int show_branch;
Matthieu Moy6a964f52013-09-12 12:50:05 +020063 int hints;
Junio C Hamanod249b092009-08-09 21:59:30 -070064
Jürgen Rühle2a3a3c22007-01-10 23:25:03 +010065 /* These are computed during processing of the individual sections */
66 int commitable;
67 int workdir_dirty;
Kristian Høgsberg0f729f22007-09-17 20:06:43 -040068 const char *index_file;
Kristian Høgsbergf26a0012007-09-17 20:06:42 -040069 FILE *fp;
Johannes Schindelin367c9882007-11-11 17:35:41 +000070 const char *prefix;
Junio C Hamano50b7e702009-08-04 23:49:33 -070071 struct string_list change;
Junio C Hamano76378682009-08-10 00:36:33 -070072 struct string_list untracked;
Junio C Hamano6cb3f6b2010-04-10 00:11:53 -070073 struct string_list ignored;
Nguyễn Thái Ngọc Duy6a38ef22013-03-13 19:59:16 +070074 uint32_t untracked_in_ms;
Jeff Kingc91f0d92006-09-08 04:05:34 -040075};
76
Lucien Kong83c750a2012-06-05 22:21:24 +020077struct wt_status_state {
78 int merge_in_progress;
79 int am_in_progress;
80 int am_empty_patch;
81 int rebase_in_progress;
82 int rebase_interactive_in_progress;
83 int cherry_pick_in_progress;
84 int bisect_in_progress;
Matthieu Moydb4ef442013-04-02 16:20:21 +020085 int revert_in_progress;
Nguyễn Thái Ngọc Duy8b87cfd2013-03-16 09:12:36 +070086 char *branch;
87 char *onto;
Nguyễn Thái Ngọc Duyb397ea42013-03-13 18:42:52 +070088 char *detached_from;
89 unsigned char detached_sha1[20];
Matthieu Moy87e139c2013-04-02 16:20:22 +020090 unsigned char revert_head_sha1[20];
Ralf Thielowbffd8092013-10-11 17:58:37 +020091 unsigned char cherry_pick_head_sha1[20];
Lucien Kong83c750a2012-06-05 22:21:24 +020092};
93
Jeff Kingc91f0d92006-09-08 04:05:34 -040094void wt_status_prepare(struct wt_status *s);
95void wt_status_print(struct wt_status *s);
Junio C Hamano76378682009-08-10 00:36:33 -070096void wt_status_collect(struct wt_status *s);
Nguyễn Thái Ngọc Duyb397ea42013-03-13 18:42:52 +070097void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
Jeff Kingc91f0d92006-09-08 04:05:34 -040098
Jeff Kingd4a6bf12012-05-07 17:09:04 -040099void wt_shortstatus_print(struct wt_status *s);
Jeff King3207a3a2012-05-07 15:44:44 -0400100void wt_porcelain_print(struct wt_status *s);
Michael J Gruber84dbe7b2009-12-05 16:04:37 +0100101
Jeff King8dd0ee82013-07-09 20:23:28 -0400102__attribute__((format (printf, 3, 4)))
103void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...);
104__attribute__((format (printf, 3, 4)))
105void status_printf(struct wt_status *s, const char *color, const char *fmt, ...);
Jonathan Niederbecbdae2011-02-25 23:09:41 -0600106
Jeff Kingc91f0d92006-09-08 04:05:34 -0400107#endif /* STATUS_H */