1#ifndef STATUS_H
2#define STATUS_H
34
#include <stdio.h>
5#include "string-list.h"
6#include "color.h"
7#include "pathspec.h"
89
struct worktree;
1011
enum color_wt_status {
12WT_STATUS_HEADER = 0,
13WT_STATUS_UPDATED,
14WT_STATUS_CHANGED,
15WT_STATUS_UNTRACKED,
16WT_STATUS_NOBRANCH,
17WT_STATUS_UNMERGED,
18WT_STATUS_LOCAL_BRANCH,
19WT_STATUS_REMOTE_BRANCH,
20WT_STATUS_ONBRANCH,
21WT_STATUS_MAXSLOT
22};
2324
enum untracked_status_type {
25SHOW_NO_UNTRACKED_FILES,
26SHOW_NORMAL_UNTRACKED_FILES,
27SHOW_ALL_UNTRACKED_FILES
28};
2930
enum show_ignored_type {
31SHOW_NO_IGNORED,
32SHOW_TRADITIONAL_IGNORED,
33SHOW_MATCHING_IGNORED,
34};
3536
/* from where does this commit originate */
37enum commit_whence {
38FROM_COMMIT, /* normal */
39FROM_MERGE, /* commit came from merge */
40FROM_CHERRY_PICK /* commit came from cherry-pick */
41};
4243
struct wt_status_change_data {
44int worktree_status;
45int index_status;
46int stagemask;
47int score;
48int mode_head, mode_index, mode_worktree;
49struct object_id oid_head, oid_index;
50char *head_path;
51unsigned dirty_submodule : 2;
52unsigned new_submodule_commits : 1;
53};
5455
enum wt_status_format {
56STATUS_FORMAT_NONE = 0,
57STATUS_FORMAT_LONG,
58STATUS_FORMAT_SHORT,
59STATUS_FORMAT_PORCELAIN,
60STATUS_FORMAT_PORCELAIN_V2,
6162
STATUS_FORMAT_UNSPECIFIED
63};
6465
struct wt_status {
66int is_initial;
67char *branch;
68const char *reference;
69struct pathspec pathspec;
70int verbose;
71int amend;
72enum commit_whence whence;
73int nowarn;
74int use_color;
75int no_gettext;
76int display_comment_prefix;
77int relative_paths;
78int submodule_summary;
79enum show_ignored_type show_ignored_mode;
80enum untracked_status_type show_untracked_files;
81const char *ignore_submodule_arg;
82char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
83unsigned colopts;
84int null_termination;
85int commit_template;
86int show_branch;
87int show_stash;
88int hints;
8990
enum wt_status_format status_format;
91unsigned char sha1_commit[GIT_MAX_RAWSZ]; /* when not Initial */
9293
/* These are computed during processing of the individual sections */
94int commitable;
95int workdir_dirty;
96const char *index_file;
97FILE *fp;
98const char *prefix;
99struct string_list change;
100struct string_list untracked;
101struct string_list ignored;
102uint32_t untracked_in_ms;
103};
104105
struct wt_status_state {
106int merge_in_progress;
107int am_in_progress;
108int am_empty_patch;
109int rebase_in_progress;
110int rebase_interactive_in_progress;
111int cherry_pick_in_progress;
112int bisect_in_progress;
113int revert_in_progress;
114int detached_at;
115char *branch;
116char *onto;
117char *detached_from;
118unsigned char detached_sha1[20];
119unsigned char revert_head_sha1[20];
120unsigned char cherry_pick_head_sha1[20];
121};
122123
size_t wt_status_locate_end(const char *s, size_t len);
124void wt_status_add_cut_line(FILE *fp);
125void wt_status_prepare(struct wt_status *s);
126void wt_status_print(struct wt_status *s);
127void wt_status_collect(struct wt_status *s);
128void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
129int wt_status_check_rebase(const struct worktree *wt,
130struct wt_status_state *state);
131int wt_status_check_bisect(const struct worktree *wt,
132struct wt_status_state *state);
133134
__attribute__((format (printf, 3, 4)))
135void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...);
136__attribute__((format (printf, 3, 4)))
137void status_printf(struct wt_status *s, const char *color, const char *fmt, ...);
138139
/* The following functions expect that the caller took care of reading the index. */
140int has_unstaged_changes(int ignore_submodules);
141int has_uncommitted_changes(int ignore_submodules);
142int require_clean_work_tree(const char *action, const char *hint,
143int ignore_submodules, int gently);
144145
#endif /* STATUS_H */