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