Merge branch 'en/t6042-insane-merge-rename-testcases'
[gitweb.git] / sequencer.c
index 39363a950f841afff28032e619a1c10e294bd857..5a068fd35116a1e664d7cefbd363e984be6cc0b6 100644 (file)
@@ -63,12 +63,12 @@ static GIT_PATH_FUNC(rebase_path_done, "rebase-merge/done")
  * The file to keep track of how many commands were already processed (e.g.
  * for the prompt).
  */
-static GIT_PATH_FUNC(rebase_path_msgnum, "rebase-merge/msgnum");
+static GIT_PATH_FUNC(rebase_path_msgnum, "rebase-merge/msgnum")
 /*
  * The file to keep track of how many commands are to be processed in total
  * (e.g. for the prompt).
  */
-static GIT_PATH_FUNC(rebase_path_msgtotal, "rebase-merge/end");
+static GIT_PATH_FUNC(rebase_path_msgtotal, "rebase-merge/end")
 /*
  * The commit message that is planned to be used for any changes that
  * need to be committed following a user interaction.
@@ -433,7 +433,7 @@ static int read_oneliner(struct strbuf *buf,
 
 static struct tree *empty_tree(void)
 {
-       return lookup_tree(the_hash_algo->empty_tree);
+       return lookup_tree(the_repository, the_repository->hash_algo->empty_tree);
 }
 
 static int error_dirty_index(struct replay_opts *opts)
@@ -594,7 +594,7 @@ static int is_index_unchanged(void)
        if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
                return error(_("could not resolve HEAD commit"));
 
-       head_commit = lookup_commit(&head_oid);
+       head_commit = lookup_commit(the_repository, &head_oid);
 
        /*
         * If head_commit is NULL, check_commit, called from
@@ -1101,7 +1101,7 @@ void print_commit_summary(const char *prefix, const struct object_id *oid,
        struct strbuf author_ident = STRBUF_INIT;
        struct strbuf committer_ident = STRBUF_INIT;
 
-       commit = lookup_commit(oid);
+       commit = lookup_commit(the_repository, oid);
        if (!commit)
                die(_("couldn't look up newly created commit"));
        if (parse_commit(commit))
@@ -1176,7 +1176,7 @@ static int parse_head(struct commit **head)
        if (get_oid("HEAD", &oid)) {
                current_head = NULL;
        } else {
-               current_head = lookup_commit_reference(&oid);
+               current_head = lookup_commit_reference(the_repository, &oid);
                if (!current_head)
                        return error(_("could not parse HEAD"));
                if (oidcmp(&oid, &current_head->object.oid)) {
@@ -1511,7 +1511,7 @@ static int update_squash_messages(enum todo_command command,
 
                if (get_oid("HEAD", &head))
                        return error(_("need a HEAD to fixup"));
-               if (!(head_commit = lookup_commit_reference(&head)))
+               if (!(head_commit = lookup_commit_reference(the_repository, &head)))
                        return error(_("could not read HEAD"));
                if (!(head_message = get_commit_buffer(head_commit, NULL)))
                        return error(_("could not read HEAD's commit message"));
@@ -1864,8 +1864,6 @@ static int prepare_revs(struct replay_opts *opts)
        if (prepare_revision_walk(opts->revs))
                return error(_("revision walk setup failed"));
 
-       if (!opts->revs->commits)
-               return error(_("empty commit set passed"));
        return 0;
 }
 
@@ -2009,7 +2007,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
        if (status < 0)
                return -1;
 
-       item->commit = lookup_commit_reference(&commit_oid);
+       item->commit = lookup_commit_reference(the_repository, &commit_oid);
        return !item->commit;
 }
 
@@ -2207,6 +2205,7 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
 static void read_strategy_opts(struct replay_opts *opts, struct strbuf *buf)
 {
        int i;
+       char *strategy_opts_string;
 
        strbuf_reset(buf);
        if (!read_oneliner(buf, rebase_path_strategy(), 0))
@@ -2215,7 +2214,11 @@ static void read_strategy_opts(struct replay_opts *opts, struct strbuf *buf)
        if (!read_oneliner(buf, rebase_path_strategy_opts(), 0))
                return;
 
-       opts->xopts_nr = split_cmdline(buf->buf, (const char ***)&opts->xopts);
+       strategy_opts_string = buf->buf;
+       if (*strategy_opts_string == ' ')
+               strategy_opts_string++;
+       opts->xopts_nr = split_cmdline(strategy_opts_string,
+                                      (const char ***)&opts->xopts);
        for (i = 0; i < opts->xopts_nr; i++) {
                const char *arg = opts->xopts[i];
 
@@ -2318,6 +2321,10 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
                        short_commit_name(commit), subject_len, subject);
                unuse_commit_buffer(commit, commit_buffer);
        }
+
+       if (!todo_list->nr)
+               return error(_("empty commit set passed"));
+
        return 0;
 }
 
@@ -3627,7 +3634,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
                        continue;
 
                if (!get_oid(name, &oid)) {
-                       if (!lookup_commit_reference_gently(&oid, 1)) {
+                       if (!lookup_commit_reference_gently(the_repository, &oid, 1)) {
                                enum object_type type = oid_object_info(the_repository,
                                                                        &oid,
                                                                        NULL);
@@ -3653,8 +3660,10 @@ int sequencer_pick_revisions(struct replay_opts *opts)
                if (prepare_revision_walk(opts->revs))
                        return error(_("revision walk setup failed"));
                cmit = get_revision(opts->revs);
-               if (!cmit || get_revision(opts->revs))
-                       return error("BUG: expected exactly one commit from walk");
+               if (!cmit)
+                       return error(_("empty commit set passed"));
+               if (get_revision(opts->revs))
+                       BUG("unexpected extra commit from walk");
                return single_pick(cmit, opts);
        }
 
@@ -4013,7 +4022,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
                entry = oidmap_get(&state.commit2label, &commit->object.oid);
 
                if (entry)
-                       fprintf(out, "\n# Branch %s\n", entry->string);
+                       fprintf(out, "\n%c Branch %s\n", comment_line_char, entry->string);
                else
                        fprintf(out, "\n");