sequencer.hon commit rebase -i: rewrite init_basic_state() in C (d59cd14)
   1#ifndef SEQUENCER_H
   2#define SEQUENCER_H
   3
   4const char *git_path_commit_editmsg(void);
   5const char *git_path_seq_dir(void);
   6const char *rebase_path_todo(void);
   7
   8#define APPEND_SIGNOFF_DEDUP (1u << 0)
   9
  10enum replay_action {
  11        REPLAY_REVERT,
  12        REPLAY_PICK,
  13        REPLAY_INTERACTIVE_REBASE
  14};
  15
  16enum 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
  23struct 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
  61enum missing_commit_check_level {
  62        MISSING_COMMIT_CHECK_IGNORE = 0,
  63        MISSING_COMMIT_CHECK_WARN,
  64        MISSING_COMMIT_CHECK_ERROR
  65};
  66
  67int 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 */
  71void sequencer_init_config(struct replay_opts *opts);
  72int sequencer_pick_revisions(struct replay_opts *opts);
  73int sequencer_continue(struct replay_opts *opts);
  74int sequencer_rollback(struct replay_opts *opts);
  75int 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)
  87int sequencer_make_script(FILE *out, int argc, const char **argv,
  88                          unsigned flags);
  89
  90int sequencer_add_exec_commands(const char *command);
  91int transform_todos(unsigned flags);
  92enum missing_commit_check_level get_missing_commit_check_level(void);
  93int check_todo_list(void);
  94int 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);
  98int rearrange_squash(void);
  99
 100extern const char sign_off_header[];
 101
 102void append_signoff(struct strbuf *msgbuf, int ignore_footer, unsigned flag);
 103void append_conflicts_hint(struct strbuf *msgbuf);
 104int message_is_empty(const struct strbuf *sb,
 105                     enum commit_msg_cleanup_mode cleanup_mode);
 106int template_untouched(const struct strbuf *sb, const char *template_file,
 107                       enum commit_msg_cleanup_mode cleanup_mode);
 108int 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);
 112void commit_post_rewrite(const struct commit *current_head,
 113                         const struct object_id *new_head);
 114
 115int prepare_branch_to_be_rebased(struct replay_opts *opts, const char *commit);
 116
 117#define SUMMARY_INITIAL_COMMIT   (1 << 0)
 118#define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)
 119void print_commit_summary(const char *prefix, const struct object_id *oid,
 120                          unsigned int flags);
 121#endif
 122
 123void parse_strategy_opts(struct replay_opts *opts, char *raw_opts);
 124int write_basic_state(struct replay_opts *opts, const char *head_name,
 125                      const char *onto, const char *orig_head);