🌐 AI搜索 & 代理 主页
blob: 8a3864783b039d92454cfda1c2ef2457e737cddd [file] [log] [blame]
Jeff Kingc91f0d92006-09-08 08:05:341#ifndef STATUS_H
2#define STATUS_H
3
Kristian Høgsbergf26a0012007-09-18 00:06:424#include <stdio.h>
Junio C Hamano50b7e702009-08-05 06:49:335#include "string-list.h"
Junio C Hamano23900a92009-08-10 06:08:406#include "color.h"
SZEDER Gábor7aa9b9b2015-08-20 14:06:277#include "pathspec.h"
Kristian Høgsbergf26a0012007-09-18 00:06:428
Nguyễn Thái Ngọc Duy81eff272016-04-22 13:01:319struct worktree;
10
Jeff Kingc91f0d92006-09-08 08:05:3411enum color_wt_status {
Junio C Hamano23900a92009-08-10 06:08:4012 WT_STATUS_HEADER = 0,
Jeff Kingc91f0d92006-09-08 08:05:3413 WT_STATUS_UPDATED,
14 WT_STATUS_CHANGED,
15 WT_STATUS_UNTRACKED,
Chris Parsons950ce2e2008-05-22 12:50:0216 WT_STATUS_NOBRANCH,
Junio C Hamano4d4d5722009-08-05 07:04:5117 WT_STATUS_UNMERGED,
Daniel Knittl-Frank05a59a02010-05-25 13:45:5118 WT_STATUS_LOCAL_BRANCH,
Aleksi Aalto1d282322010-11-17 23:40:0519 WT_STATUS_REMOTE_BRANCH,
20 WT_STATUS_ONBRANCH,
21 WT_STATUS_MAXSLOT
Jeff Kingc91f0d92006-09-08 08:05:3422};
23
Marius Storm-Olsen4bfee302008-06-05 08:31:1924enum untracked_status_type {
Marius Storm-Olsen6c2ce042008-06-05 12:22:5625 SHOW_NO_UNTRACKED_FILES,
26 SHOW_NORMAL_UNTRACKED_FILES,
Marius Storm-Olsen4bfee302008-06-05 08:31:1927 SHOW_ALL_UNTRACKED_FILES
28};
Marius Storm-Olsen4bfee302008-06-05 08:31:1929
Jay Soffian37f7a852011-02-20 04:12:2930/* 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-05 06:49:3337struct wt_status_change_data {
38 int worktree_status;
39 int index_status;
40 int stagemask;
Jeff Hostetler1ecdecc2016-08-11 14:45:5741 int score;
42 int mode_head, mode_index, mode_worktree;
43 struct object_id oid_head, oid_index;
Junio C Hamano50b7e702009-08-05 06:49:3344 char *head_path;
Jens Lehmann9297f77e62010-03-08 12:53:1945 unsigned dirty_submodule : 2;
46 unsigned new_submodule_commits : 1;
Junio C Hamano50b7e702009-08-05 06:49:3347};
48
Jeff Hostetlerbe7e7952016-08-05 22:00:2749enum wt_status_format {
50 STATUS_FORMAT_NONE = 0,
51 STATUS_FORMAT_LONG,
52 STATUS_FORMAT_SHORT,
53 STATUS_FORMAT_PORCELAIN,
Jeff Hostetler1ecdecc2016-08-11 14:45:5754 STATUS_FORMAT_PORCELAIN_V2,
Jeff Hostetlerbe7e7952016-08-05 22:00:2755
56 STATUS_FORMAT_UNSPECIFIED
57};
58
Jeff Kingc91f0d92006-09-08 08:05:3459struct wt_status {
60 int is_initial;
61 char *branch;
62 const char *reference;
Nguyễn Thái Ngọc Duy15b55ae2013-07-14 08:35:3963 struct pathspec pathspec;
Jeff Kingc91f0d92006-09-08 08:05:3464 int verbose;
65 int amend;
Jay Soffian37f7a852011-02-20 04:12:2966 enum commit_whence whence;
Junio C Hamano37d07f82007-12-13 03:09:1667 int nowarn;
Junio C Hamanod249b092009-08-10 04:59:3068 int use_color;
Matthieu Moy7a76c282014-03-20 12:12:4169 int no_gettext;
Matthieu Moy2556b992013-09-06 17:43:0770 int display_comment_prefix;
Junio C Hamanod249b092009-08-10 04:59:3071 int relative_paths;
72 int submodule_summary;
Junio C Hamano6cb3f6b2010-04-10 07:11:5373 int show_ignored_files;
Junio C Hamanod249b092009-08-10 04:59:3074 enum untracked_status_type show_untracked_files;
Jens Lehmann46a958b2010-06-25 14:56:4775 const char *ignore_submodule_arg;
Aleksi Aalto1d282322010-11-17 23:40:0576 char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
Jeff King4d2292e2012-05-07 19:35:0377 unsigned colopts;
Jeff King3207a3a2012-05-07 19:44:4478 int null_termination;
Jeff Kingd4a6bf12012-05-07 21:09:0479 int show_branch;
Matthieu Moy6a964f52013-09-12 10:50:0580 int hints;
Junio C Hamanod249b092009-08-10 04:59:3081
Jeff Hostetlerbe7e7952016-08-05 22:00:2782 enum wt_status_format status_format;
brian m. carlsoncd025992017-03-26 16:01:2583 unsigned char sha1_commit[GIT_MAX_RAWSZ]; /* when not Initial */
Jeff Hostetlerbe7e7952016-08-05 22:00:2784
Jürgen Rühle2a3a3c22007-01-10 22:25:0385 /* These are computed during processing of the individual sections */
86 int commitable;
87 int workdir_dirty;
Kristian Høgsberg0f729f22007-09-18 00:06:4388 const char *index_file;
Kristian Høgsbergf26a0012007-09-18 00:06:4289 FILE *fp;
Johannes Schindelin367c9882007-11-11 17:35:4190 const char *prefix;
Junio C Hamano50b7e702009-08-05 06:49:3391 struct string_list change;
Junio C Hamano76378682009-08-10 07:36:3392 struct string_list untracked;
Junio C Hamano6cb3f6b2010-04-10 07:11:5393 struct string_list ignored;
Nguyễn Thái Ngọc Duy6a38ef22013-03-13 12:59:1694 uint32_t untracked_in_ms;
Jeff Kingc91f0d92006-09-08 08:05:3495};
96
Lucien Kong83c750a2012-06-05 20:21:2497struct wt_status_state {
98 int merge_in_progress;
99 int am_in_progress;
100 int am_empty_patch;
101 int rebase_in_progress;
102 int rebase_interactive_in_progress;
103 int cherry_pick_in_progress;
104 int bisect_in_progress;
Matthieu Moydb4ef442013-04-02 14:20:21105 int revert_in_progress;
Michael J Gruber970399e2015-03-06 15:04:06106 int detached_at;
Nguyễn Thái Ngọc Duy8b87cfd2013-03-16 02:12:36107 char *branch;
108 char *onto;
Nguyễn Thái Ngọc Duyb397ea42013-03-13 11:42:52109 char *detached_from;
110 unsigned char detached_sha1[20];
Matthieu Moy87e139c2013-04-02 14:20:22111 unsigned char revert_head_sha1[20];
Ralf Thielowbffd8092013-10-11 15:58:37112 unsigned char cherry_pick_head_sha1[20];
Lucien Kong83c750a2012-06-05 20:21:24113};
114
Brian Malehornd76650b2017-05-16 06:06:49115size_t wt_status_locate_end(const char *s, size_t len);
Nguyễn Thái Ngọc Duyfcef9312014-02-17 12:15:31116void wt_status_add_cut_line(FILE *fp);
Jeff Kingc91f0d92006-09-08 08:05:34117void wt_status_prepare(struct wt_status *s);
Jeff Hostetlerbe7e7952016-08-05 22:00:27118void wt_status_print(struct wt_status *s);
Junio C Hamano76378682009-08-10 07:36:33119void wt_status_collect(struct wt_status *s);
Nguyễn Thái Ngọc Duyb397ea42013-03-13 11:42:52120void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
Nguyễn Thái Ngọc Duy81eff272016-04-22 13:01:31121int wt_status_check_rebase(const struct worktree *wt,
122 struct wt_status_state *state);
Nguyễn Thái Ngọc Duyf5d067a2016-04-22 13:01:34123int wt_status_check_bisect(const struct worktree *wt,
124 struct wt_status_state *state);
Jeff Kingc91f0d92006-09-08 08:05:34125
Jeff King8dd0ee82013-07-10 00:23:28126__attribute__((format (printf, 3, 4)))
127void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...);
128__attribute__((format (printf, 3, 4)))
129void status_printf(struct wt_status *s, const char *color, const char *fmt, ...);
Jonathan Niederbecbdae2011-02-26 05:09:41130
Johannes Schindelin41a5dd62016-10-07 16:08:56131/* The following functions expect that the caller took care of reading the index. */
Johannes Schindelind8cc92a2016-10-07 16:09:00132int has_unstaged_changes(int ignore_submodules);
133int has_uncommitted_changes(int ignore_submodules);
134int require_clean_work_tree(const char *action, const char *hint,
135 int ignore_submodules, int gently);
Johannes Schindelinfd849862016-10-07 16:08:38136
Jeff Kingc91f0d92006-09-08 08:05:34137#endif /* STATUS_H */