wt-status.h 3.1 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
struct wt_status_change_data {
	int worktree_status;
	int index_status;
	int stagemask;
41 42 43
	int score;
	int mode_head, mode_index, mode_worktree;
	struct object_id oid_head, oid_index;
44
	char *head_path;
45 46
	unsigned dirty_submodule       : 2;
	unsigned new_submodule_commits : 1;
47 48
};

49 50 51 52 53
enum wt_status_format {
	STATUS_FORMAT_NONE = 0,
	STATUS_FORMAT_LONG,
	STATUS_FORMAT_SHORT,
	STATUS_FORMAT_PORCELAIN,
54
	STATUS_FORMAT_PORCELAIN_V2,
55 56 57 58

	STATUS_FORMAT_UNSPECIFIED
};

59 60 61 62
struct wt_status {
	int is_initial;
	char *branch;
	const char *reference;
63
	struct pathspec pathspec;
64 65
	int verbose;
	int amend;
66
	enum commit_whence whence;
67
	int nowarn;
68
	int use_color;
69
	int no_gettext;
70
	int display_comment_prefix;
71 72
	int relative_paths;
	int submodule_summary;
73
	int show_ignored_files;
74
	enum untracked_status_type show_untracked_files;
75
	const char *ignore_submodule_arg;
76
	char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
77
	unsigned colopts;
78
	int null_termination;
79
	int show_branch;
80
	int hints;
81

82 83
	enum wt_status_format status_format;

84 85 86
	/* These are computed during processing of the individual sections */
	int commitable;
	int workdir_dirty;
87
	const char *index_file;
88
	FILE *fp;
89
	const char *prefix;
90
	struct string_list change;
91
	struct string_list untracked;
92
	struct string_list ignored;
93
	uint32_t untracked_in_ms;
94 95
};

96 97 98 99 100 101 102 103
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;
104
	int revert_in_progress;
105
	int detached_at;
106 107
	char *branch;
	char *onto;
108 109
	char *detached_from;
	unsigned char detached_sha1[20];
110
	unsigned char revert_head_sha1[20];
111
	unsigned char cherry_pick_head_sha1[20];
112 113
};

114
void wt_status_truncate_message_at_cut_line(struct strbuf *);
115
void wt_status_add_cut_line(FILE *fp);
116
void wt_status_prepare(struct wt_status *s);
117
void wt_status_print(struct wt_status *s);
118
void wt_status_collect(struct wt_status *s);
119
void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
120 121
int wt_status_check_rebase(const struct worktree *wt,
			   struct wt_status_state *state);
122 123
int wt_status_check_bisect(const struct worktree *wt,
			   struct wt_status_state *state);
124

125 126 127 128
__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, ...);
129

130
#endif /* STATUS_H */