summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c69
1 files changed, 30 insertions, 39 deletions
diff --git a/sequencer.c b/sequencer.c
index 1ee0abbd45..5476d39ba9 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -13,7 +13,7 @@
#include "dir.h"
#include "object-file.h"
#include "object-name.h"
-#include "object-store.h"
+#include "odb.h"
#include "object.h"
#include "pager.h"
#include "commit.h"
@@ -327,7 +327,7 @@ static int git_sequencer_config(const char *k, const char *v,
void sequencer_init_config(struct replay_opts *opts)
{
opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_NONE;
- git_config(git_sequencer_config, opts);
+ repo_config(the_repository, git_sequencer_config, opts);
}
static inline int is_rebase_i(const struct replay_opts *opts)
@@ -1087,7 +1087,6 @@ N_("you have staged changes in your working tree\n"
#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)
{
@@ -1125,9 +1124,6 @@ static int run_git_commit(const char *defmsg,
{
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) &&
@@ -1166,8 +1162,6 @@ static int run_git_commit(const char *defmsg,
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) &&
@@ -1540,9 +1534,6 @@ static int try_to_commit(struct repository *r,
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;
@@ -1618,8 +1609,6 @@ static int try_to_commit(struct repository *r,
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;
@@ -2067,6 +2056,9 @@ static int update_squash_messages(struct repository *r,
const char *message, *body;
const char *encoding = get_commit_output_encoding();
+ if (!is_fixup(command))
+ BUG("not a FIXUP or SQUASH %d", command);
+
if (ctx->current_fixup_count > 0) {
struct strbuf header = STRBUF_INIT;
char *eol;
@@ -2134,8 +2126,7 @@ static int update_squash_messages(struct repository *r,
strbuf_addstr(&buf, "\n\n");
strbuf_add_commented_lines(&buf, body, strlen(body),
comment_line_str);
- } else
- return error(_("unknown command: %d"), command);
+ }
repo_unuse_commit_buffer(r, commit, message);
if (!res)
@@ -2434,7 +2425,6 @@ static int do_pick_commit(struct repository *r,
if (!final_fixup)
msg_file = rebase_path_squash_msg();
else if (file_exists(rebase_path_fixup_msg())) {
- flags |= VERBATIM_MSG;
msg_file = rebase_path_fixup_msg();
} else {
const char *dest = git_path_squash_msg(r);
@@ -2719,6 +2709,7 @@ static int check_merge_commit_insn(enum todo_command command)
return error(_("cannot squash merge commit into another commit"));
case TODO_MERGE:
+ case TODO_DROP:
return 0;
default:
@@ -3648,57 +3639,57 @@ static int save_opts(struct replay_opts *opts)
int res = 0;
if (opts->no_commit)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.no-commit", NULL, "true");
if (opts->edit >= 0)
- res |= git_config_set_in_file_gently(opts_file, "options.edit", NULL,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file, "options.edit", NULL,
opts->edit ? "true" : "false");
if (opts->allow_empty)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.allow-empty", NULL, "true");
if (opts->allow_empty_message)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.allow-empty-message", NULL, "true");
if (opts->drop_redundant_commits)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.drop-redundant-commits", NULL, "true");
if (opts->keep_redundant_commits)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.keep-redundant-commits", NULL, "true");
if (opts->signoff)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.signoff", NULL, "true");
if (opts->record_origin)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.record-origin", NULL, "true");
if (opts->allow_ff)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.allow-ff", NULL, "true");
if (opts->mainline) {
struct strbuf buf = STRBUF_INIT;
strbuf_addf(&buf, "%d", opts->mainline);
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.mainline", NULL, buf.buf);
strbuf_release(&buf);
}
if (opts->strategy)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.strategy", NULL, opts->strategy);
if (opts->gpg_sign)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.gpg-sign", NULL, opts->gpg_sign);
for (size_t i = 0; i < opts->xopts.nr; i++)
- res |= git_config_set_multivar_in_file_gently(opts_file,
+ res |= repo_config_set_multivar_in_file_gently(the_repository, opts_file,
"options.strategy-option",
opts->xopts.v[i], "^$", NULL, 0);
if (opts->allow_rerere_auto)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.allow-rerere-auto", NULL,
opts->allow_rerere_auto == RERERE_AUTOUPDATE ?
"true" : "false");
if (opts->explicit_cleanup)
- res |= git_config_set_in_file_gently(opts_file,
+ res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.default-msg-cleanup", NULL,
describe_cleanup_mode(opts->default_msg_cleanup));
return res;
@@ -5503,9 +5494,8 @@ int sequencer_pick_revisions(struct repository *r,
if (!repo_get_oid(r, name, &oid)) {
if (!lookup_commit_reference_gently(r, &oid, 1)) {
- enum object_type type = oid_object_info(r,
- &oid,
- NULL);
+ enum object_type type = odb_read_object_info(r->objects,
+ &oid, NULL);
res = error(_("%s: can't cherry-pick a %s"),
name, type_name(type));
goto out;
@@ -5833,7 +5823,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
*cmd_reset = abbr ? "t" : "reset",
*cmd_merge = abbr ? "m" : "merge";
- git_config_get_int("rebase.maxlabellength", &state.max_label_length);
+ repo_config_get_int(the_repository, "rebase.maxlabellength", &state.max_label_length);
oidmap_init(&commit2todo, 0);
oidmap_init(&state.commit2label, 0);
@@ -6062,8 +6052,8 @@ static int make_script_with_merges(struct pretty_print_context *pp,
return 0;
}
-int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
- const char **argv, unsigned flags)
+int sequencer_make_script(struct repository *r, struct strbuf *out,
+ struct strvec *argv, unsigned flags)
{
char *format = NULL;
struct pretty_print_context pp = {0};
@@ -6088,7 +6078,7 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
revs.topo_order = 1;
revs.pretty_given = 1;
- git_config_get_string("rebase.instructionFormat", &format);
+ repo_config_get_string(the_repository, "rebase.instructionFormat", &format);
if (!format || !*format) {
free(format);
format = xstrdup("# %s");
@@ -6104,7 +6094,8 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
pp.fmt = revs.commit_format;
pp.output_encoding = get_log_output_encoding();
- if (setup_revisions(argc, argv, &revs, NULL) > 1) {
+ setup_revisions_from_strvec(argv, &revs, NULL);
+ if (argv->nr > 1) {
ret = error(_("make_script: unhandled options"));
goto cleanup;
}