]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'cm/rebase-i-updates'
authorJunio C Hamano <gitster@pobox.com>
Fri, 26 Mar 2021 21:59:03 +0000 (14:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Mar 2021 21:59:03 +0000 (14:59 -0700)
Follow-up fixes to "cm/rebase-i" topic.

* cm/rebase-i-updates:
  doc/rebase -i: fix typo in the documentation of 'fixup' command
  t/t3437: fixup the test 'multiple fixup -c opens editor once'
  t/t3437: use named commits in the tests
  t/t3437: simplify and document the test helpers
  t/t3437: check the author date of fixed up commit
  t/t3437: remove the dependency of 'expected-message' file from tests
  t/t3437: fixup here-docs in the 'setup' test
  t/lib-rebase: update the documentation of FAKE_LINES
  rebase -i: clarify and fix 'fixup -c' rebase-todo help
  sequencer: rename a few functions
  sequencer: fixup the datatype of the 'flag' argument

1  2 
sequencer.c
t/lib-rebase.sh

diff --combined sequencer.c
index e32020252d6cd2c78b7f5942eb01df68bf35a0e0,abc6d5cdfd45005d1edd1cef9ed6c4a6c854a117..aedca2d52b926b658385a39c970ef5e8c4ddfe00
@@@ -679,6 -679,9 +679,6 @@@ static int do_recursive_merge(struct re
  
  static struct object_id *get_cache_tree_oid(struct index_state *istate)
  {
 -      if (!istate->cache_tree)
 -              istate->cache_tree = cache_tree();
 -
        if (!cache_tree_fully_valid(istate->cache_tree))
                if (cache_tree_update(istate, 0)) {
                        error(_("unable to update cache tree"));
@@@ -940,7 -943,6 +940,7 @@@ N_("you have staged changes in your wor
  #define CLEANUP_MSG (1<<3)
  #define VERIFY_MSG  (1<<4)
  #define CREATE_ROOT_COMMIT (1<<5)
 +#define VERBATIM_MSG (1<<6)
  
  static int run_command_silent_on_success(struct child_process *cmd)
  {
@@@ -977,9 -979,6 +977,9 @@@ static int run_git_commit(const char *d
  {
        struct child_process cmd = CHILD_PROCESS_INIT;
  
 +      if ((flags & CLEANUP_MSG) && (flags & VERBATIM_MSG))
 +              BUG("CLEANUP_MSG and VERBATIM_MSG are mutually exclusive");
 +
        cmd.git_cmd = 1;
  
        if (is_rebase_i(opts) && read_env_script(&cmd.env_array)) {
                strvec_pushl(&cmd.args, "-C", "HEAD", NULL);
        if ((flags & CLEANUP_MSG))
                strvec_push(&cmd.args, "--cleanup=strip");
 +      if ((flags & VERBATIM_MSG))
 +              strvec_push(&cmd.args, "--cleanup=verbatim");
        if ((flags & EDIT_MSG))
                strvec_push(&cmd.args, "-e");
        else if (!(flags & CLEANUP_MSG) &&
@@@ -1383,9 -1380,6 +1383,9 @@@ static int try_to_commit(struct reposit
        enum commit_msg_cleanup_mode cleanup;
        int res = 0;
  
 +      if ((flags & CLEANUP_MSG) && (flags & VERBATIM_MSG))
 +              BUG("CLEANUP_MSG and VERBATIM_MSG are mutually exclusive");
 +
        if (parse_head(r, &current_head))
                return -1;
  
  
        if (flags & CLEANUP_MSG)
                cleanup = COMMIT_MSG_CLEANUP_ALL;
 +      else if (flags & VERBATIM_MSG)
 +              cleanup = COMMIT_MSG_CLEANUP_NONE;
        else if ((opts->signoff || opts->record_origin) &&
                 !opts->explicit_cleanup)
                cleanup = COMMIT_MSG_CLEANUP_SPACE;
@@@ -1752,8 -1744,7 +1752,7 @@@ static const char skip_first_commit_msg
  static const char skip_nth_commit_msg_fmt[] = N_("The commit message #%d will be skipped:");
  static const char combined_commit_msg_fmt[] = N_("This is a combination of %d commits.");
  
- static int check_fixup_flag(enum todo_command command,
-                           enum todo_item_flags flag)
+ static int is_fixup_flag(enum todo_command command, unsigned flag)
  {
        return command == TODO_FIXUP && ((flag & TODO_REPLACE_FIXUP_MSG) ||
                                         (flag & TODO_EDIT_FIXUP_MSG));
@@@ -1858,7 -1849,7 +1857,7 @@@ static void update_squash_message_for_f
  
  static int append_squash_message(struct strbuf *buf, const char *body,
                         enum todo_command command, struct replay_opts *opts,
-                        enum todo_item_flags flag)
+                        unsigned flag)
  {
        const char *fixup_msg;
        size_t commented_len = 0, fixup_off;
        strbuf_addstr(buf, body + commented_len);
  
        /* fixup -C after squash behaves like squash */
-       if (check_fixup_flag(command, flag) && !seen_squash(opts)) {
+       if (is_fixup_flag(command, flag) && !seen_squash(opts)) {
                /*
                 * We're replacing the commit message so we need to
                 * append the Signed-off-by: trailer if the user
@@@ -1914,7 -1905,7 +1913,7 @@@ static int update_squash_messages(struc
                                  enum todo_command command,
                                  struct commit *commit,
                                  struct replay_opts *opts,
-                                 enum todo_item_flags flag)
+                                 unsigned flag)
  {
        struct strbuf buf = STRBUF_INIT;
        int res = 0;
                            opts->current_fixup_count + 2);
                strbuf_splice(&buf, 0, eol - buf.buf, header.buf, header.len);
                strbuf_release(&header);
-               if (check_fixup_flag(command, flag) && !seen_squash(opts))
+               if (is_fixup_flag(command, flag) && !seen_squash(opts))
                        update_squash_message_for_fixup(&buf);
        } else {
                struct object_id head;
                strbuf_addf(&buf, "%c ", comment_line_char);
                strbuf_addf(&buf, _(combined_commit_msg_fmt), 2);
                strbuf_addf(&buf, "\n%c ", comment_line_char);
-               strbuf_addstr(&buf, check_fixup_flag(command, flag) ?
+               strbuf_addstr(&buf, is_fixup_flag(command, flag) ?
                              _(skip_first_commit_msg_str) :
                              _(first_commit_msg_str));
                strbuf_addstr(&buf, "\n\n");
-               if (check_fixup_flag(command, flag))
+               if (is_fixup_flag(command, flag))
                        strbuf_add_commented_lines(&buf, body, strlen(body));
                else
                        strbuf_addstr(&buf, body);
                             oid_to_hex(&commit->object.oid));
        find_commit_subject(message, &body);
  
-       if (command == TODO_SQUASH || check_fixup_flag(command, flag)) {
+       if (command == TODO_SQUASH || is_fixup_flag(command, flag)) {
                res = append_squash_message(&buf, body, command, opts, flag);
        } else if (command == TODO_FIXUP) {
                strbuf_addf(&buf, "\n%c ", comment_line_char);
@@@ -2199,7 -2190,7 +2198,7 @@@ static int do_pick_commit(struct reposi
                if (!final_fixup)
                        msg_file = rebase_path_squash_msg();
                else if (file_exists(rebase_path_fixup_msg())) {
 -                      flags |= CLEANUP_MSG;
 +                      flags |= VERBATIM_MSG;
                        msg_file = rebase_path_fixup_msg();
                } else {
                        const char *dest = git_path_squash_msg(r);
@@@ -5371,7 -5362,7 +5370,7 @@@ void todo_list_add_exec_commands(struc
        int i, insert, nr = 0, alloc = 0;
        struct todo_item *items = NULL, *base_items = NULL;
  
 -      base_items = xcalloc(commands->nr, sizeof(struct todo_item));
 +      CALLOC_ARRAY(base_items, commands->nr);
        for (i = 0; i < commands->nr; i++) {
                size_t command_len = strlen(commands->items[i].string);
  
@@@ -5670,7 -5661,7 +5669,7 @@@ static int subject2item_cmp(const void 
  
  define_commit_slab(commit_todo_item, struct todo_item *);
  
- static inline int skip_fixup_amend_squash(const char *subject, const char **p) {
+ static int skip_fixupish(const char *subject, const char **p) {
        return skip_prefix(subject, "fixup! ", p) ||
               skip_prefix(subject, "amend! ", p) ||
               skip_prefix(subject, "squash! ", p);
@@@ -5734,13 -5725,13 +5733,13 @@@ int todo_list_rearrange_squash(struct t
                format_subject(&buf, subject, " ");
                subject = subjects[i] = strbuf_detach(&buf, &subject_len);
                unuse_commit_buffer(item->commit, commit_buffer);
-               if (skip_fixup_amend_squash(subject, &p)) {
+               if (skip_fixupish(subject, &p)) {
                        struct commit *commit2;
  
                        for (;;) {
                                while (isspace(*p))
                                        p++;
-                               if (!skip_fixup_amend_squash(p, &p))
+                               if (!skip_fixupish(p, &p))
                                        break;
                        }
  
diff --combined t/lib-rebase.sh
index 27928ecb94c32f779e3d450f5b9a652fe830f919,57cee517b2c4cdc89a74d8baf75cbee5246f25c1..dc75b834518c8f2d2e1cc9e54fdc8d6af2729125
  #       specified line.
  #
  #   "<cmd> <lineno>" -- add a line with the specified command
- #       ("pick", "squash", "fixup", "edit", "reword" or "drop") and the
- #       SHA1 taken from the specified line.
+ #       ("pick", "squash", "fixup"|"fixup_-C"|"fixup_-c", "edit", "reword" or "drop")
+ #       and the SHA1 taken from the specified line.
  #
- #   "exec_cmd_with_args" -- add an "exec cmd with args" line.
+ #   "_" -- add a space, like "fixup_-C" implies "fixup -C" and
+ #       "exec_cmd_with_args" add an "exec cmd with args" line.
  #
  #   "#" -- Add a comment line.
  #
@@@ -30,6 -31,7 +31,6 @@@ set_fake_editor () 
        */COMMIT_EDITMSG)
                test -z "$EXPECT_HEADER_COUNT" ||
                        test "$EXPECT_HEADER_COUNT" = "$(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1")" ||
 -                      test "# # GETTEXT POISON #" = "$(sed -n '1p' < "$1")" ||
                        exit
                test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
                test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"