]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ag/sequencer-reduce-rewriting-todo'
authorJunio C Hamano <gitster@pobox.com>
Thu, 25 Apr 2019 07:41:11 +0000 (16:41 +0900)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Apr 2019 07:41:11 +0000 (16:41 +0900)
The scripted version of "git rebase -i" wrote and rewrote the todo
list many times during a single step of its operation, and the
recent C-rewrite made a faithful conversion of the logic to C.  The
implementation has been updated to carry necessary information
around in-core to avoid rewriting the same file over and over
unnecessarily.

* ag/sequencer-reduce-rewriting-todo:
  rebase--interactive: move transform_todo_file()
  sequencer: use edit_todo_list() in complete_action()
  rebase-interactive: rewrite edit_todo_list() to handle the initial edit
  rebase-interactive: append_todo_help() changes
  rebase-interactive: use todo_list_write_to_file() in edit_todo_list()
  sequencer: refactor skip_unnecessary_picks() to work on a todo_list
  rebase--interactive: move rearrange_squash_in_todo_file()
  rebase--interactive: move sequencer_add_exec_commands()
  sequencer: change complete_action() to use the refactored functions
  sequencer: make sequencer_make_script() write its script to a strbuf
  sequencer: refactor rearrange_squash() to work on a todo_list
  sequencer: refactor sequencer_add_exec_commands() to work on a todo_list
  sequencer: refactor check_todo_list() to work on a todo_list
  sequencer: introduce todo_list_write_to_file()
  sequencer: refactor transform_todos() to work on a todo_list
  sequencer: remove the 'arg' field from todo_item
  sequencer: make the todo_list structure public
  sequencer: changes in parse_insn_buffer()

1  2 
builtin/rebase--interactive.c
sequencer.c
sequencer.h

Simple merge
diff --cc sequencer.c
index 79a046d748300d76ec66f5fd4cd0cb0e681b5651,2a0fcb1cce19494723b9327e6f3b96b98cafe635..7f4056dbf42e88d412c8772a9ec9b0fa6a8a1746
@@@ -2133,12 -2084,12 +2093,13 @@@ static int parse_insn_line(struct repos
        status = get_oid(bol, &commit_oid);
        *end_of_object_name = saved;
  
-       item->arg = end_of_object_name + strspn(end_of_object_name, " \t");
-       item->arg_len = (int)(eol - item->arg);
+       bol = end_of_object_name + strspn(end_of_object_name, " \t");
+       item->arg_offset = bol - buf;
+       item->arg_len = (int)(eol - bol);
  
        if (status < 0)
 -              return -1;
 +              return error(_("could not parse '%.*s'"),
 +                           (int)(end_of_object_name - bol), bol);
  
        item->commit = lookup_commit_reference(r, &commit_oid);
        return !item->commit;
@@@ -3638,13 -3589,13 +3605,13 @@@ static int pick_commits(struct reposito
                        struct stat st;
  
                        *end_of_arg = '\0';
-                       res = do_exec(r, item->arg);
+                       res = do_exec(r, arg);
                        *end_of_arg = saved;
  
 -                      /* Reread the todo file if it has changed. */
 -                      if (res)
 -                              ; /* fall through */
 -                      else if (stat(get_todo_path(opts), &st))
 +                      if (res) {
 +                              if (opts->reschedule_failed_exec)
 +                                      reschedule = 1;
 +                      else if (stat(get_todo_path(opts), &st))
                                res = error_errno(_("could not stat '%s'"),
                                                  get_todo_path(opts));
                        else if (match_stat_data(&todo_list->stat, &st)) {
diff --cc sequencer.h
index 4d505b3590ed158600844cfe3889112b5da4e511,7cca49eff2f02222dc64012d0505a5d4af4d162a..a515ee44578e6d8a568544749278c67feb4d233a
@@@ -93,20 -138,22 +140,20 @@@ int sequencer_remove_state(struct repla
   * commits should be rebased onto the new base, this flag needs to be passed.
   */
  #define TODO_LIST_REBASE_COUSINS (1U << 4)
- int sequencer_make_script(struct repository *repo, FILE *out,
-                         int argc, const char **argv,
-                         unsigned flags);
- int sequencer_add_exec_commands(struct repository *r, const char *command);
- int transform_todos(struct repository *r, unsigned flags);
enum missing_commit_check_level get_missing_commit_check_level(void);
- int check_todo_list(struct repository *r);
+ #define TODO_LIST_APPEND_TODO_HELP (1U << 5)
+ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
+                         const char **argv, unsigned flags);
+ void todo_list_add_exec_commands(struct todo_list *todo_list,
                               struct string_list *commands);
+ int check_todo_list_from_file(struct repository *r);
  int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
                    const char *shortrevisions, const char *onto_name,
-                   const char *onto, const char *orig_head, const char *cmd,
-                   unsigned autosquash);
- int rearrange_squash(struct repository *r);
+                   const char *onto, const char *orig_head, struct string_list *commands,
+                   unsigned autosquash, struct todo_list *todo_list);
+ int todo_list_rearrange_squash(struct todo_list *todo_list);
  
 -extern const char sign_off_header[];
 -
  /*
   * Append a signoff to the commit message in "msgbuf". The ignore_footer
   * parameter specifies the number of bytes at the end of msgbuf that should