rebase (autostash): avoid duplicate call to state_dir_path()
[git/gitster.git] / sequencer.h
blobaab280f276a55bdc0af81027dc497aa34354ee52
1 #ifndef SEQUENCER_H
2 #define SEQUENCER_H
4 const char *git_path_commit_editmsg(void);
5 const char *git_path_seq_dir(void);
6 const char *rebase_path_todo(void);
8 #define APPEND_SIGNOFF_DEDUP (1u << 0)
10 enum replay_action {
11 REPLAY_REVERT,
12 REPLAY_PICK,
13 REPLAY_INTERACTIVE_REBASE
16 enum commit_msg_cleanup_mode {
17 COMMIT_MSG_CLEANUP_SPACE,
18 COMMIT_MSG_CLEANUP_NONE,
19 COMMIT_MSG_CLEANUP_SCISSORS,
20 COMMIT_MSG_CLEANUP_ALL
23 struct replay_opts {
24 enum replay_action action;
26 /* Boolean options */
27 int edit;
28 int record_origin;
29 int no_commit;
30 int signoff;
31 int allow_ff;
32 int allow_rerere_auto;
33 int allow_empty;
34 int allow_empty_message;
35 int keep_redundant_commits;
36 int verbose;
38 int mainline;
40 char *gpg_sign;
41 enum commit_msg_cleanup_mode default_msg_cleanup;
43 /* Merge strategy */
44 char *strategy;
45 char **xopts;
46 size_t xopts_nr, xopts_alloc;
48 /* Used by fixup/squash */
49 struct strbuf current_fixups;
50 int current_fixup_count;
52 /* placeholder commit for -i --root */
53 struct object_id squash_onto;
54 int have_squash_onto;
56 /* Only used by REPLAY_NONE */
57 struct rev_info *revs;
59 #define REPLAY_OPTS_INIT { .action = -1, .current_fixups = STRBUF_INIT }
61 enum missing_commit_check_level {
62 MISSING_COMMIT_CHECK_IGNORE = 0,
63 MISSING_COMMIT_CHECK_WARN,
64 MISSING_COMMIT_CHECK_ERROR
67 int write_message(const void *buf, size_t len, const char *filename,
68 int append_eol);
70 /* Call this to setup defaults before parsing command line options */
71 void sequencer_init_config(struct replay_opts *opts);
72 int sequencer_pick_revisions(struct replay_opts *opts);
73 int sequencer_continue(struct replay_opts *opts);
74 int sequencer_rollback(struct replay_opts *opts);
75 int sequencer_remove_state(struct replay_opts *opts);
77 #define TODO_LIST_KEEP_EMPTY (1U << 0)
78 #define TODO_LIST_SHORTEN_IDS (1U << 1)
79 #define TODO_LIST_ABBREVIATE_CMDS (1U << 2)
80 #define TODO_LIST_REBASE_MERGES (1U << 3)
82 * When rebasing merges, commits that do have the base commit as ancestor
83 * ("cousins") are *not* rebased onto the new base by default. If those
84 * commits should be rebased onto the new base, this flag needs to be passed.
86 #define TODO_LIST_REBASE_COUSINS (1U << 4)
87 int sequencer_make_script(FILE *out, int argc, const char **argv,
88 unsigned flags);
90 int sequencer_add_exec_commands(const char *command);
91 int transform_todos(unsigned flags);
92 enum missing_commit_check_level get_missing_commit_check_level(void);
93 int check_todo_list(void);
94 int complete_action(struct replay_opts *opts, unsigned flags,
95 const char *shortrevisions, const char *onto_name,
96 const char *onto, const char *orig_head, const char *cmd,
97 unsigned autosquash);
98 int rearrange_squash(void);
100 extern const char sign_off_header[];
102 void append_signoff(struct strbuf *msgbuf, int ignore_footer, unsigned flag);
103 void append_conflicts_hint(struct strbuf *msgbuf);
104 int message_is_empty(const struct strbuf *sb,
105 enum commit_msg_cleanup_mode cleanup_mode);
106 int template_untouched(const struct strbuf *sb, const char *template_file,
107 enum commit_msg_cleanup_mode cleanup_mode);
108 int update_head_with_reflog(const struct commit *old_head,
109 const struct object_id *new_head,
110 const char *action, const struct strbuf *msg,
111 struct strbuf *err);
112 void commit_post_rewrite(const struct commit *current_head,
113 const struct object_id *new_head);
115 int prepare_branch_to_be_rebased(struct replay_opts *opts, const char *commit);
117 #define SUMMARY_INITIAL_COMMIT (1 << 0)
118 #define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)
119 void print_commit_summary(const char *prefix, const struct object_id *oid,
120 unsigned int flags);
121 #endif
123 void parse_strategy_opts(struct replay_opts *opts, char *raw_opts);
124 int write_basic_state(struct replay_opts *opts, const char *head_name,
125 const char *onto, const char *orig_head);