replace-object.c: mark more strings for translation
[gitweb.git] / sequencer.c
index 560fc9b67d480069328d379421c606d800e82135..6b6162d1947a55102964439aee22feae2f1a0ed2 100644 (file)
@@ -27,6 +27,7 @@
 #include "worktree.h"
 #include "oidmap.h"
 #include "oidset.h"
+#include "commit-slab.h"
 #include "alias.h"
 
 #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
@@ -175,6 +176,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
                        warning(_("invalid commit message cleanup mode '%s'"),
                                  s);
 
+               free((char *)s);
                return status;
        }
 
@@ -304,7 +306,7 @@ static const char *action_name(const struct replay_opts *opts)
        case REPLAY_INTERACTIVE_REBASE:
                return N_("rebase -i");
        }
-       die(_("Unknown action: %d"), opts->action);
+       die(_("unknown action: %d"), opts->action);
 }
 
 struct commit_message {
@@ -784,7 +786,7 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
        struct child_process cmd = CHILD_PROCESS_INIT;
        const char *value;
 
-       if (flags & CREATE_ROOT_COMMIT) {
+       if ((flags & CREATE_ROOT_COMMIT) && !(flags & AMEND_MSG)) {
                struct strbuf msg = STRBUF_INIT, script = STRBUF_INIT;
                const char *author = is_rebase_i(opts) ?
                        read_author_ident(&script) : NULL;
@@ -1442,7 +1444,7 @@ static const char *command_to_string(const enum todo_command command)
 {
        if (command < TODO_COMMENT)
                return todo_command_info[command].str;
-       die("Unknown command: %d", command);
+       die("unknown command: %d", command);
 }
 
 static char command_to_char(const enum todo_command command)
@@ -1773,7 +1775,8 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
                res = do_recursive_merge(base, next, base_label, next_label,
                                         &head, &msgbuf, opts);
                if (res < 0)
-                       return res;
+                       goto leave;
+
                res |= write_message(msgbuf.buf, msgbuf.len,
                                     git_path_merge_msg(), 0);
        } else {
@@ -2605,7 +2608,7 @@ static int error_with_patch(struct commit *commit,
                        "\n"
                        "  git rebase --continue\n", gpg_sign_opt_quoted(opts));
        } else if (exit_code)
-               fprintf(stderr, "Could not apply %s... %.*s\n",
+               fprintf_ln(stderr, "Could not apply %s... %.*s",
                        short_commit_name(commit), subject_len, subject);
 
        return exit_code;
@@ -2716,7 +2719,7 @@ static int do_label(const char *name, int len)
        struct object_id head_oid;
 
        if (len == 1 && *name == '#')
-               return error("Illegal label name: '%.*s'", len, name);
+               return error("illegal label name: '%.*s'", len, name);
 
        strbuf_addf(&ref_name, "refs/rewritten/%.*s", len, name);
        strbuf_addf(&msg, "rebase -i (label) '%.*s'", len, name);
@@ -3792,7 +3795,7 @@ static const char *label_oid(struct object_id *oid, const char *label,
                                p[i] = save;
                        }
                }
-       } else if (((len = strlen(label)) == GIT_SHA1_RAWSZ &&
+       } else if (((len = strlen(label)) == the_hash_algo->hexsz &&
                    !get_oid_hex(label, &dummy)) ||
                   (len == 1 && *label == '#') ||
                   hashmap_get_from_hash(&state->labels,
@@ -4238,6 +4241,7 @@ static enum check_level get_missing_commit_check_level(void)
        return CHECK_IGNORE;
 }
 
+define_commit_slab(commit_seen, unsigned char);
 /*
  * Check if the user dropped some commits by mistake
  * Behaviour determined by rebase.missingCommitsCheck.
@@ -4251,6 +4255,9 @@ int check_todo_list(void)
        struct todo_list todo_list = TODO_LIST_INIT;
        struct strbuf missing = STRBUF_INIT;
        int advise_to_edit_todo = 0, res = 0, i;
+       struct commit_seen commit_seen;
+
+       init_commit_seen(&commit_seen);
 
        strbuf_addstr(&todo_file, rebase_path_todo());
        if (strbuf_read_file_or_whine(&todo_list.buf, todo_file.buf) < 0) {
@@ -4267,7 +4274,7 @@ int check_todo_list(void)
        for (i = 0; i < todo_list.nr; i++) {
                struct commit *commit = todo_list.items[i].commit;
                if (commit)
-                       commit->util = (void *)1;
+                       *commit_seen_at(&commit_seen, commit) = 1;
        }
 
        todo_list_release(&todo_list);
@@ -4283,11 +4290,11 @@ int check_todo_list(void)
        for (i = todo_list.nr - 1; i >= 0; i--) {
                struct todo_item *item = todo_list.items + i;
                struct commit *commit = item->commit;
-               if (commit && !commit->util) {
+               if (commit && !*commit_seen_at(&commit_seen, commit)) {
                        strbuf_addf(&missing, " - %s %.*s\n",
                                    short_commit_name(commit),
                                    item->arg_len, item->arg);
-                       commit->util = (void *)1;
+                       *commit_seen_at(&commit_seen, commit) = 1;
                }
        }
 
@@ -4313,6 +4320,7 @@ int check_todo_list(void)
                "The possible behaviours are: ignore, warn, error.\n\n"));
 
 leave_check:
+       clear_commit_seen(&commit_seen);
        strbuf_release(&todo_file);
        todo_list_release(&todo_list);
 
@@ -4433,6 +4441,8 @@ static int subject2item_cmp(const void *fndata,
        return key ? strcmp(a->subject, key) : strcmp(a->subject, b->subject);
 }
 
+define_commit_slab(commit_todo_item, struct todo_item *);
+
 /*
  * Rearrange the todo list that has both "pick commit-id msg" and "pick
  * commit-id fixup!/squash! msg" in it so that the latter is put immediately
@@ -4449,6 +4459,7 @@ int rearrange_squash(void)
        struct hashmap subject2item;
        int res = 0, rearranged = 0, *next, *tail, i;
        char **subjects;
+       struct commit_todo_item commit_todo;
 
        if (strbuf_read_file_or_whine(&todo_list.buf, todo_file) < 0)
                return -1;
@@ -4457,6 +4468,7 @@ int rearrange_squash(void)
                return -1;
        }
 
+       init_commit_todo_item(&commit_todo);
        /*
         * The hashmap maps onelines to the respective todo list index.
         *
@@ -4487,10 +4499,11 @@ int rearrange_squash(void)
 
                if (is_fixup(item->command)) {
                        todo_list_release(&todo_list);
+                       clear_commit_todo_item(&commit_todo);
                        return error(_("the script was already rearranged."));
                }
 
-               item->commit->util = item;
+               *commit_todo_item_at(&commit_todo, item->commit) = item;
 
                parse_commit(item->commit);
                commit_buffer = get_commit_buffer(item->commit, NULL);
@@ -4517,9 +4530,9 @@ int rearrange_squash(void)
                        else if (!strchr(p, ' ') &&
                                 (commit2 =
                                  lookup_commit_reference_by_name(p)) &&
-                                commit2->util)
+                                *commit_todo_item_at(&commit_todo, commit2))
                                /* found by commit name */
-                               i2 = (struct todo_item *)commit2->util
+                               i2 = *commit_todo_item_at(&commit_todo, commit2)
                                        - todo_list.items;
                        else {
                                /* copy can be a prefix of the commit subject */
@@ -4596,5 +4609,6 @@ int rearrange_squash(void)
        hashmap_free(&subject2item, 1);
        todo_list_release(&todo_list);
 
+       clear_commit_todo_item(&commit_todo);
        return res;
 }