else if (item->command == TODO_RESET)
res = do_reset(item->arg, item->arg_len, opts);
else if (item->command == TODO_MERGE ||
- item->command == TODO_MERGE_AND_EDIT)
+ item->command == TODO_MERGE_AND_EDIT) {
res = do_merge(item->commit, item->arg, item->arg_len,
item->command == TODO_MERGE_AND_EDIT ?
EDIT_MSG | VERIFY_MSG : 0, opts);
- else if (!is_noop(item->command))
+ if (item->commit)
+ record_in_rewritten(&item->commit->object.oid,
+ peek_command(todo_list, 1));
+ } else if (!is_noop(item->command))
return error(_("unknown command %d"), item->command);
todo_list->current++;
test_cmp_rev HEAD "$(cat wt/b)"
'
+test_expect_success 'post-rewrite hook and fixups work for merges' '
+ git checkout -b post-rewrite &&
+ test_commit same1 &&
+ git reset --hard HEAD^ &&
+ test_commit same2 &&
+ git merge -m "to fix up" same1 &&
+ echo same old same old >same2.t &&
+ test_tick &&
+ git commit --fixup HEAD same2.t &&
+ fixup="$(git rev-parse HEAD)" &&
+
+ mkdir -p .git/hooks &&
+ test_when_finished "rm .git/hooks/post-rewrite" &&
+ echo "cat >actual" | write_script .git/hooks/post-rewrite &&
+
+ test_tick &&
+ git rebase -i --autosquash --recreate-merges HEAD^^^ &&
+ printf "%s %s\n%s %s\n%s %s\n%s %s\n" >expect $(git rev-parse \
+ $fixup^^2 HEAD^2 \
+ $fixup^^ HEAD^ \
+ $fixup^ HEAD \
+ $fixup HEAD) &&
+ test_cmp expect actual
+'
+
test_done