1#ifndef SEQUENCER_H
2#define SEQUENCER_H
3
4const char *git_path_commit_editmsg(void);
5const char *git_path_seq_dir(void);
6
7#define APPEND_SIGNOFF_DEDUP (1u << 0)
8
9enum replay_action {
10 REPLAY_REVERT,
11 REPLAY_PICK,
12 REPLAY_INTERACTIVE_REBASE
13};
14
15enum commit_msg_cleanup_mode {
16 COMMIT_MSG_CLEANUP_SPACE,
17 COMMIT_MSG_CLEANUP_NONE,
18 COMMIT_MSG_CLEANUP_SCISSORS,
19 COMMIT_MSG_CLEANUP_ALL
20};
21
22struct replay_opts {
23 enum replay_action action;
24
25 /* Boolean options */
26 int edit;
27 int record_origin;
28 int no_commit;
29 int signoff;
30 int allow_ff;
31 int allow_rerere_auto;
32 int allow_empty;
33 int allow_empty_message;
34 int keep_redundant_commits;
35 int verbose;
36
37 int mainline;
38
39 char *gpg_sign;
40 enum commit_msg_cleanup_mode default_msg_cleanup;
41
42 /* Merge strategy */
43 char *strategy;
44 char **xopts;
45 size_t xopts_nr, xopts_alloc;
46
47 /* placeholder commit for -i --root */
48 struct object_id squash_onto;
49 int have_squash_onto;
50
51 /* Only used by REPLAY_NONE */
52 struct rev_info *revs;
53};
54#define REPLAY_OPTS_INIT { -1 }
55
56/* Call this to setup defaults before parsing command line options */
57void sequencer_init_config(struct replay_opts *opts);
58int sequencer_pick_revisions(struct replay_opts *opts);
59int sequencer_continue(struct replay_opts *opts);
60int sequencer_rollback(struct replay_opts *opts);
61int sequencer_remove_state(struct replay_opts *opts);
62
63#define TODO_LIST_KEEP_EMPTY (1U << 0)
64#define TODO_LIST_SHORTEN_IDS (1U << 1)
65#define TODO_LIST_ABBREVIATE_CMDS (1U << 2)
66#define TODO_LIST_REBASE_MERGES (1U << 3)
67/*
68 * When rebasing merges, commits that do have the base commit as ancestor
69 * ("cousins") are *not* rebased onto the new base by default. If those
70 * commits should be rebased onto the new base, this flag needs to be passed.
71 */
72#define TODO_LIST_REBASE_COUSINS (1U << 4)
73int sequencer_make_script(FILE *out, int argc, const char **argv,
74 unsigned flags);
75
76int sequencer_add_exec_commands(const char *command);
77int transform_todos(unsigned flags);
78int check_todo_list(void);
79int skip_unnecessary_picks(void);
80int rearrange_squash(void);
81
82extern const char sign_off_header[];
83
84void append_signoff(struct strbuf *msgbuf, int ignore_footer, unsigned flag);
85void append_conflicts_hint(struct strbuf *msgbuf);
86int message_is_empty(const struct strbuf *sb,
87 enum commit_msg_cleanup_mode cleanup_mode);
88int template_untouched(const struct strbuf *sb, const char *template_file,
89 enum commit_msg_cleanup_mode cleanup_mode);
90int update_head_with_reflog(const struct commit *old_head,
91 const struct object_id *new_head,
92 const char *action, const struct strbuf *msg,
93 struct strbuf *err);
94void commit_post_rewrite(const struct commit *current_head,
95 const struct object_id *new_head);
96
97#define SUMMARY_INITIAL_COMMIT (1 << 0)
98#define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)
99void print_commit_summary(const char *prefix, const struct object_id *oid,
100 unsigned int flags);
101#endif