]> git.ipfire.org Git - thirdparty/git.git/blob - sequencer.h
rebase -i: rewrite complete_action() in C
[thirdparty/git.git] / sequencer.h
1 #ifndef SEQUENCER_H
2 #define SEQUENCER_H
3
4 const char *git_path_commit_editmsg(void);
5 const char *git_path_seq_dir(void);
6 const char *rebase_path_todo(void);
7
8 #define APPEND_SIGNOFF_DEDUP (1u << 0)
9
10 enum replay_action {
11 REPLAY_REVERT,
12 REPLAY_PICK,
13 REPLAY_INTERACTIVE_REBASE
14 };
15
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
21 };
22
23 struct replay_opts {
24 enum replay_action action;
25
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;
37
38 int mainline;
39
40 char *gpg_sign;
41 enum commit_msg_cleanup_mode default_msg_cleanup;
42
43 /* Merge strategy */
44 char *strategy;
45 char **xopts;
46 size_t xopts_nr, xopts_alloc;
47
48 /* Used by fixup/squash */
49 struct strbuf current_fixups;
50 int current_fixup_count;
51
52 /* placeholder commit for -i --root */
53 struct object_id squash_onto;
54 int have_squash_onto;
55
56 /* Only used by REPLAY_NONE */
57 struct rev_info *revs;
58 };
59 #define REPLAY_OPTS_INIT { .action = -1, .current_fixups = STRBUF_INIT }
60
61 enum missing_commit_check_level {
62 MISSING_COMMIT_CHECK_IGNORE = 0,
63 MISSING_COMMIT_CHECK_WARN,
64 MISSING_COMMIT_CHECK_ERROR
65 };
66
67 int write_message(const void *buf, size_t len, const char *filename,
68 int append_eol);
69
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);
76
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)
81 /*
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.
85 */
86 #define TODO_LIST_REBASE_COUSINS (1U << 4)
87 int sequencer_make_script(FILE *out, int argc, const char **argv,
88 unsigned flags);
89
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 skip_unnecessary_picks(struct object_id *output_oid);
95 int complete_action(struct replay_opts *opts, unsigned flags,
96 const char *shortrevisions, const char *onto_name,
97 const char *onto, const char *orig_head, const char *cmd,
98 unsigned autosquash);
99 int rearrange_squash(void);
100
101 extern const char sign_off_header[];
102
103 void append_signoff(struct strbuf *msgbuf, int ignore_footer, unsigned flag);
104 void append_conflicts_hint(struct strbuf *msgbuf);
105 int message_is_empty(const struct strbuf *sb,
106 enum commit_msg_cleanup_mode cleanup_mode);
107 int template_untouched(const struct strbuf *sb, const char *template_file,
108 enum commit_msg_cleanup_mode cleanup_mode);
109 int update_head_with_reflog(const struct commit *old_head,
110 const struct object_id *new_head,
111 const char *action, const struct strbuf *msg,
112 struct strbuf *err);
113 void commit_post_rewrite(const struct commit *current_head,
114 const struct object_id *new_head);
115
116 int prepare_branch_to_be_rebased(struct replay_opts *opts, const char *commit);
117 int checkout_onto(struct replay_opts *opts,
118 const char *onto_name, const char *onto,
119 const char *orig_head);
120
121 #define SUMMARY_INITIAL_COMMIT (1 << 0)
122 #define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)
123 void print_commit_summary(const char *prefix, const struct object_id *oid,
124 unsigned int flags);
125 #endif