wt-status.h 2.89 KB
Newer Older
1 2 3
#ifndef STATUS_H
#define STATUS_H

4
#include <stdio.h>
5
#include "string-list.h"
6
#include "color.h"
7
#include "pathspec.h"
8

9 10
struct worktree;

11
enum color_wt_status {
12
	WT_STATUS_HEADER = 0,
13 14 15
	WT_STATUS_UPDATED,
	WT_STATUS_CHANGED,
	WT_STATUS_UNTRACKED,
16
	WT_STATUS_NOBRANCH,
17
	WT_STATUS_UNMERGED,
18
	WT_STATUS_LOCAL_BRANCH,
19 20 21
	WT_STATUS_REMOTE_BRANCH,
	WT_STATUS_ONBRANCH,
	WT_STATUS_MAXSLOT
22 23
};

24
enum untracked_status_type {
25 26
	SHOW_NO_UNTRACKED_FILES,
	SHOW_NORMAL_UNTRACKED_FILES,
27 28 29
	SHOW_ALL_UNTRACKED_FILES
};

30 31 32 33 34 35 36
/* from where does this commit originate */
enum commit_whence {
	FROM_COMMIT,     /* normal */
	FROM_MERGE,      /* commit came from merge */
	FROM_CHERRY_PICK /* commit came from cherry-pick */
};

37 38 39 40 41
struct wt_status_change_data {
	int worktree_status;
	int index_status;
	int stagemask;
	char *head_path;
42 43
	unsigned dirty_submodule       : 2;
	unsigned new_submodule_commits : 1;
44 45
};

46 47 48 49
struct wt_status {
	int is_initial;
	char *branch;
	const char *reference;
50
	struct pathspec pathspec;
51 52
	int verbose;
	int amend;
53
	enum commit_whence whence;
54
	int nowarn;
55
	int use_color;
56
	int no_gettext;
57
	int display_comment_prefix;
58 59
	int relative_paths;
	int submodule_summary;
60
	int show_ignored_files;
61
	enum untracked_status_type show_untracked_files;
62
	const char *ignore_submodule_arg;
63
	char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
64
	unsigned colopts;
65
	int null_termination;
66
	int show_branch;
67
	int hints;
68

69 70 71
	/* These are computed during processing of the individual sections */
	int commitable;
	int workdir_dirty;
72
	const char *index_file;
73
	FILE *fp;
74
	const char *prefix;
75
	struct string_list change;
76
	struct string_list untracked;
77
	struct string_list ignored;
78
	uint32_t untracked_in_ms;
79 80
};

81 82 83 84 85 86 87 88
struct wt_status_state {
	int merge_in_progress;
	int am_in_progress;
	int am_empty_patch;
	int rebase_in_progress;
	int rebase_interactive_in_progress;
	int cherry_pick_in_progress;
	int bisect_in_progress;
89
	int revert_in_progress;
90
	int detached_at;
91 92
	char *branch;
	char *onto;
93 94
	char *detached_from;
	unsigned char detached_sha1[20];
95
	unsigned char revert_head_sha1[20];
96
	unsigned char cherry_pick_head_sha1[20];
97 98
};

99
void wt_status_truncate_message_at_cut_line(struct strbuf *);
100
void wt_status_add_cut_line(FILE *fp);
101
void wt_status_prepare(struct wt_status *s);
102
void wt_status_collect(struct wt_status *s);
103
void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
104 105
int wt_status_check_rebase(const struct worktree *wt,
			   struct wt_status_state *state);
106 107
int wt_status_check_bisect(const struct worktree *wt,
			   struct wt_status_state *state);
108

109
void wt_longstatus_print(struct wt_status *s);
110
void wt_shortstatus_print(struct wt_status *s);
111
void wt_porcelain_print(struct wt_status *s);
112

113 114 115 116
__attribute__((format (printf, 3, 4)))
void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...);
__attribute__((format (printf, 3, 4)))
void status_printf(struct wt_status *s, const char *color, const char *fmt, ...);
117

118
#endif /* STATUS_H */